6 Commits
1.1.0 ... 2.2.0

Author SHA1 Message Date
71360614d6 read() return null insted of false 2026-03-08 23:23:49 +05:00
670d7a0730 commits merging 2 2025-12-24 22:23:00 +05:00
b08051ccd3 commits merging 2025-12-24 22:20:24 +05:00
beccbfee1e namespace conflict fix 2025-12-24 22:15:06 +05:00
14c2629fb3 Merge branch 'stable' of https://git.svoboda.works/mirzaev/record into stable 2025-11-04 02:07:01 +07:00
a5a79f2143 a little fix 2025-11-04 02:05:31 +07:00
7 changed files with 45 additions and 112 deletions

1
.gitignore vendored Normal file → Executable file
View File

@@ -1 +1,2 @@
vendor
composer.lock

0
LICENSE Normal file → Executable file
View File

0
README.md Normal file → Executable file
View File

0
composer.json Normal file → Executable file
View File

97
composer.lock generated
View File

@@ -1,97 +0,0 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "0c82d08a56b9613dcd0f25c1e08ce433",
"packages": [
{
"name": "mirzaev/baza",
"version": "3.4.0",
"source": {
"type": "git",
"url": "https://git.svoboda.works/mirzaev/baza",
"reference": "ec2721dc7727ebcd43b780892f3df6831dfff06b"
},
"require": {
"php": "^8.4"
},
"type": "database",
"autoload": {
"psr-4": {
"mirzaev\\baza\\": "mirzaev/baza/system/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"WTFPL"
],
"authors": [
{
"name": "Arsen Mirzaev Tatyano-Muradovich",
"email": "arsen@mirzaev.sexy",
"homepage": "https://mirzaev.sexy",
"role": "Programmer"
}
],
"description": "Lightweight binary database by pure PHP",
"homepage": "https://git.svoboda.works/mirzaev/baza",
"keywords": [
"Plain",
"binary",
"lightweight"
],
"support": {
"email": "arsen@mirzaev.sexy",
"issues": "https://git.svoboda.works/mirzaev/baza/issues",
"wiki": "https://git.svoboda.works/mirzaev/baza/wiki"
},
"time": "2025-08-08T14:27:29+00:00"
},
{
"name": "svoboda/time",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://git.svoboda.works/svoboda/time",
"reference": "0764960606d56a9f0865ebb07671d30a7d232b6a"
},
"require": {
"php": "^8.4"
},
"type": "library",
"autoload": {
"psr-4": {
"svoboda\\time\\": "svoboda/time/system"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"WTFPL"
],
"authors": [
{
"name": "Arsen Mirzaev Tatyano-Muradovich",
"email": "arsen@mirzaev.sexy",
"homepage": "https://mirzaev.sexy",
"role": "Programmer"
}
],
"description": "Time since Svoboda was created",
"homepage": "https://git.svoboda.works/svoboda/time",
"time": "2025-02-02T11:04:25+00:00"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": {},
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
"php": "^8.4"
},
"platform-dev": {},
"plugin-api-version": "2.6.0"
}

14
mirzaev/record/system/interfaces/record.php Normal file → Executable file
View File

@@ -4,6 +4,9 @@ declare(strict_types=1);
namespace mirzaev\record\interfaces;
// Baza database
use mirzaev\baza\record as baza_record;
// Built-in libraries
use InvalidArgumentException as exception_invalid_argument;
@@ -16,7 +19,8 @@ use InvalidArgumentException as exception_invalid_argument;
*
* @package mirzaev\record\interfaces
*
* @method static|false read(callable $filter) Read from the database
* @method void __construct(record|null $record) Constructor
* @method static|null read(callable $filter) Read from the database
* @method static|false update() Update the record in the database
*
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
@@ -29,18 +33,20 @@ interface record
*
* @throws exception_invalid_argument If not initialized the database columns parameters
*
* @param baza_record|null $record The record
*
* @return void
*/
public function __construct();
public function __construct(?baza_record $record = null);
/**
* Read
*
* Search for the record in the database
*
* @return static|false The record impementator object, if found
* @return static|null The record implementator object
*/
public function read(callable $filter): static|false;
public function read(callable $filter): ?static;
/**
* Update

45
mirzaev/record/system/traits/record.php Normal file → Executable file
View File

@@ -10,7 +10,7 @@ use svoboda\time\statement as svoboda;
// Baza database
use mirzaev\baza\database,
mirzaev\baza\column,
mirzaev\baza\record as baza,
mirzaev\baza\record as baza_record,
mirzaev\baza\enumerations\encoding,
mirzaev\baza\enumerations\type;
@@ -30,7 +30,7 @@ use Exception as exception,
* @package mirzaev\record\traits
*
* @method self __construct(?record $record) Constructor
* @method static|false read(callable $filter) Read from the database
* @method static|null read(callable $filter) Read from the database
* @method static|false update() Update the record in the database
* @method void __set(string $name, mixed $value = null) Write into the database record property
* @method mixed __get(string $name) Read from the database record property
@@ -44,18 +44,41 @@ trait record
/**
* Record
*
* @var baza $record The record instance
* @var baza_record $record The record instance
*/
protected baza $record;
protected baza_record $record;
/**
* Constructor
*
* @method baza_record|null $record The record
*
* @return void
*/
public function __construct(?baza_record $record = null)
{
// Initializing the database
/* $this->database = new database()
->encoding(encoding::utf8)
->columns(
new column('identifier', type::long_long_unsigned),
new column('updated', type::integer_unsigned),
new column('created', type::integer_unsigned)
)
->connect($this->file); */
// Initializing the record
$record instanceof baza_record and $this->record = $record;
}
/**
* Read
*
* Search for the record in the database
*
* @return static|false The record impementator object, if found
* @return static|null The record implementator object
*/
public function read(callable $filter): static|false
public function read(callable $filter): ?static
{
// Reading from the database
$record = $this->database->read(
@@ -64,7 +87,7 @@ trait record
offset: 0
)[0] ?? false;
if ($record instanceof baza) {
if ($record instanceof baza_record) {
// Initialized the record
// Exit (success)
@@ -72,7 +95,7 @@ trait record
}
// Exit (fail)
return false;
return null;
}
/**
@@ -86,8 +109,8 @@ trait record
{
// Writing into the database
$record = $this->database->read(
filter: fn(baza $record) => $record->identifier === $this->record->identifier,
update: function (baza &$record) {
filter: fn(baza_record $record) => $record->identifier === $this->record->identifier,
update: function (baza_record &$record) {
$this->record->updated = svoboda::timestamp();
$record = $this->record;
},
@@ -95,7 +118,7 @@ trait record
offset: 0
)[0] ?? false;
if ($record instanceof record) {
if ($record instanceof baza_record) {
// Initialized the record
// Exit (success)