1 Commits

Author SHA1 Message Date
1ad13ddd3f __construct(?record $record) 2025-11-16 12:59:13 +03:00
6 changed files with 13 additions and 10 deletions

0
.gitignore vendored Executable file → Normal file
View File

0
LICENSE Executable file → Normal file
View File

0
README.md Executable file → Normal file
View File

0
composer.json Executable file → Normal file
View File

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

@@ -4,6 +4,9 @@ declare(strict_types=1);
namespace mirzaev\record\interfaces;
// Baza database
use mirzaev\baza\record as baza;
// Built-in libraries
use InvalidArgumentException as exception_invalid_argument;
@@ -16,6 +19,7 @@ use InvalidArgumentException as exception_invalid_argument;
*
* @package mirzaev\record\interfaces
*
* @method void __construct(record|null $record) Constructor
* @method static|false read(callable $filter) Read from the database
* @method static|false update() Update the record in the database
*
@@ -31,7 +35,7 @@ interface record
*
* @return void
*/
public function __construct();
public function __construct(?baza $record = null);
/**
* Read

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

@@ -10,8 +10,7 @@ use svoboda\time\statement as svoboda;
// Baza database
use mirzaev\baza\database,
mirzaev\baza\column,
mirzaev\baza\record as baza_record,
mirzaev\baza\enumerations\encoding,
mirzaev\baza\record as baza,
mirzaev\baza\enumerations\type;
// Built-in libraries
@@ -44,9 +43,9 @@ trait record
/**
* Record
*
* @var baza_record $record The record instance
* @var baza $record The record instance
*/
protected baza_record $record;
protected baza $record;
/**
* Constructor
@@ -68,7 +67,7 @@ trait record
->connect($this->file); */
// Initializing the record
$record instanceof baza_record and $this->record = $record;
$record instanceof record and $this->record = $record;
}
/**
@@ -87,7 +86,7 @@ trait record
offset: 0
)[0] ?? false;
if ($record instanceof baza_record) {
if ($record instanceof baza) {
// Initialized the record
// Exit (success)
@@ -109,8 +108,8 @@ trait record
{
// Writing into the database
$record = $this->database->read(
filter: fn(baza_record $record) => $record->identifier === $this->record->identifier,
update: function (baza_record &$record) {
filter: fn(baza $record) => $record->identifier === $this->record->identifier,
update: function (baza &$record) {
$this->record->updated = svoboda::timestamp();
$record = $this->record;
},
@@ -118,7 +117,7 @@ trait record
offset: 0
)[0] ?? false;
if ($record instanceof baza_record) {
if ($record instanceof record) {
// Initialized the record
// Exit (success)