created readme for 1.0.0
This commit is contained in:
parent
f56de9b053
commit
65d729d6a9
71
README.md
71
README.md
|
@ -1,36 +1,69 @@
|
|||
# Ebaboba database
|
||||
A lightweight database by pure PHP<br>
|
||||
# Ebaboba
|
||||
Lightweight binary database by pure PHP<br>
|
||||
|
||||
At the moment the project is a modified RFC 4180
|
||||
|
||||
`2024.12.14` **IN DEVELOPMENT! DO NOT USE IN PROJECTS!**
|
||||
|
||||
## Requirements
|
||||
- PHP 8.4
|
||||
## Dependencies
|
||||
1. ![PHP 8.4](https://www.php.net/releases/8.4/en.php)
|
||||
2. ![Composer](https://getcomposer.org/) (php package manager)
|
||||
|
||||
## Installation
|
||||
1. `composer require mirzaev/ebaboba`
|
||||
2. Create a class that inherits `mirzaev/ebaboba/database` and redefine the `database::FILE` constant
|
||||
3. Enjoy!
|
||||
`composer require mirzaev/ebaboba`
|
||||
|
||||
## Example
|
||||
```php
|
||||
<?php
|
||||
|
||||
// Ebaboba database
|
||||
use mirzaev\ebaboba\{database, record};
|
||||
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('name', 'age', 'created');
|
||||
$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 = new record(['Arsen', '23', time());
|
||||
$record = $database->record(
|
||||
'Arsen',
|
||||
'Mirzaev',
|
||||
23,
|
||||
(float) 165
|
||||
);
|
||||
|
||||
// Writing to the database
|
||||
$database->write($record);
|
||||
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
|
||||
- My site-article about how i was kidnapped by PMC Wagner operatives [mirzaev/repression](https://git.mirzaev.sexy/mirzaev/repression)
|
||||
- My decentralized P2P blockchain chats project [mirzaev/notchat](https://git.mirzaev.sexy/mirzaev/notchat)
|
||||
- My site-article about how i was kidnapped by PMC Wagner operatives [mirzaev/repression](https://git.svoboda.works/mirzaev/repression)
|
||||
- My decentralized P2P blockchain chats project [mirzaev/notchat](https://git.svoboda.works/mirzaev/notchat)
|
||||
- Svoboda Telegram chat-robot [svoboda/negotiator](https://git.svoboda.works/svoboda/negotiator)
|
||||
|
|
Loading…
Reference in New Issue