Lightweight binary database by pure PHP
Go to file
Arsen Mirzaev Tatyano-Muradovich 23e03fef14 renamed from ebaboba to baza; resolved #13 2025-01-28 14:14:13 +07:00
mirzaev/baza renamed from ebaboba to baza; resolved #13 2025-01-28 14:14:13 +07:00
.gitignore move from mirzaev/repression 2024-11-23 09:50:05 +07:00
LICENSE move from mirzaev/repression 2024-11-23 09:50:05 +07:00
README.md created readme for 1.0.0 2025-01-28 14:07:30 +07:00
composer.json renamed from ebaboba to baza; resolved #13 2025-01-28 14:14:13 +07:00
composer.lock renamed from ebaboba to baza; resolved #13 2025-01-28 14:14:13 +07:00

Ebaboba

Lightweight binary database by pure PHP

Dependencies

  1. PHP 8.4
  2. Composer (php package manager)

Installation

composer require mirzaev/ebaboba

Example

<?php

use use mirzaev\ebaboba\database,
	mirzaev\ebaboba\column,
	mirzaev\ebaboba\record,
	mirzaev\ebaboba\enumerations\encoding,
	mirzaev\ebaboba\enumerations\type;

// Initializing the database
$database = new database()
	->encoding(encoding::utf8)
	->columns(
		new column('name', type::string, ['length' => 32]),
		new column('second_name', type::string, ['length' => 64]),
		new column('age', type::integer),
		new column('height', type::float)
	)
	->connect(__DIR__ . DIRECTORY_SEPARATOR . 'database.ba');

// Initializing the record
$record = $database->record(
	'Arsen',
	'Mirzaev',
	23,
	(float) 165
);

if ($database->write($record)) {
    // Writed the record into the database

    // Updating the record in the database
    $updated = $database->read(
        filter: fn($record) => $record->name === 'Arsen', 
        update: fn(&$record) => $record->age = 24, 
        amount: 1
    );

    // Reading the record from the database
    $readed = $database->read(
        filter: fn($record) => $record->name === 'Arsen' && $record->age === 24,
        amount: 1
    );

    // Deleting the record from the database
    $deleted = $database->read(
        filter: fn($record) => $record->age < 25,
        delete: true,
        amount: 1000
    );
}
?>

Used by