3 Commits
2.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
2 changed files with 37 additions and 8 deletions

View File

@@ -4,6 +4,9 @@ declare(strict_types=1);
namespace mirzaev\record\interfaces; namespace mirzaev\record\interfaces;
// Baza database
use mirzaev\baza\record as baza_record;
// Built-in libraries // Built-in libraries
use InvalidArgumentException as exception_invalid_argument; use InvalidArgumentException as exception_invalid_argument;
@@ -16,7 +19,8 @@ use InvalidArgumentException as exception_invalid_argument;
* *
* @package mirzaev\record\interfaces * @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 * @method static|false update() Update the record in the database
* *
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License * @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 * @throws exception_invalid_argument If not initialized the database columns parameters
* *
* @param baza_record|null $record The record
*
* @return void * @return void
*/ */
public function __construct(); public function __construct(?baza_record $record = null);
/** /**
* Read * Read
* *
* Search for the record in the database * 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 * Update

View File

@@ -30,7 +30,7 @@ use Exception as exception,
* @package mirzaev\record\traits * @package mirzaev\record\traits
* *
* @method self __construct(?record $record) Constructor * @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 static|false update() Update the record in the database
* @method void __set(string $name, mixed $value = null) Write into the database record property * @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 * @method mixed __get(string $name) Read from the database record property
@@ -48,14 +48,37 @@ trait record
*/ */
protected baza_record $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 * Read
* *
* Search for the record in the database * 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 // Reading from the database
$record = $this->database->read( $record = $this->database->read(
@@ -72,7 +95,7 @@ trait record
} }
// Exit (fail) // Exit (fail)
return false; return null;
} }
/** /**