Compare commits
5 Commits
1.0.0
...
14c2629fb3
| Author | SHA1 | Date | |
|---|---|---|---|
| 14c2629fb3 | |||
| a5a79f2143 | |||
| b1ee745aac | |||
| c2d6667120 | |||
| c1b1b124ba |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +1,2 @@
|
|||||||
vendor
|
vendor
|
||||||
|
composer.lock
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
# record
|
# Active Record pattern for Baza
|
||||||
|
Simple Active Record pattern implementation for [mirzaev/baza](https://git.svoboda.works/mirzaev/baza)
|
||||||
|
|
||||||
Active Record pattern for `mirzaev/baza`
|
## Installation
|
||||||
|
```bash
|
||||||
|
composer require mirzaev/record
|
||||||
|
```
|
||||||
|
|||||||
97
composer.lock
generated
97
composer.lock
generated
@@ -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"
|
|
||||||
}
|
|
||||||
@@ -4,21 +4,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace mirzaev\record\interfaces;
|
namespace mirzaev\record\interfaces;
|
||||||
|
|
||||||
// Svoboda time
|
|
||||||
use svoboda\time\statement as svoboda;
|
|
||||||
|
|
||||||
// Baza database
|
|
||||||
use mirzaev\baza\database,
|
|
||||||
mirzaev\baza\column,
|
|
||||||
mirzaev\baza\record,
|
|
||||||
mirzaev\baza\enumerations\encoding,
|
|
||||||
mirzaev\baza\enumerations\type;
|
|
||||||
|
|
||||||
// Built-in libraries
|
// Built-in libraries
|
||||||
use Exception as exception,
|
use InvalidArgumentException as exception_invalid_argument;
|
||||||
RuntimeException as exception_runtime,
|
|
||||||
LogicException as exception_logic,
|
|
||||||
InvalidArgumentException as exception_invalid_argument;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Active Record
|
* Active Record
|
||||||
@@ -35,7 +22,7 @@ use Exception as exception,
|
|||||||
* @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
|
||||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||||
*/
|
*/
|
||||||
interface ar
|
interface record
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ use svoboda\time\statement as svoboda;
|
|||||||
// Baza database
|
// Baza database
|
||||||
use mirzaev\baza\database,
|
use mirzaev\baza\database,
|
||||||
mirzaev\baza\column,
|
mirzaev\baza\column,
|
||||||
mirzaev\baza\record,
|
mirzaev\baza\record as baza,
|
||||||
mirzaev\baza\enumerations\encoding,
|
mirzaev\baza\enumerations\encoding,
|
||||||
mirzaev\baza\enumerations\type;
|
mirzaev\baza\enumerations\type;
|
||||||
|
|
||||||
@@ -41,6 +41,13 @@ use Exception as exception,
|
|||||||
*/
|
*/
|
||||||
trait record
|
trait record
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Record
|
||||||
|
*
|
||||||
|
* @var baza $record The record instance
|
||||||
|
*/
|
||||||
|
protected baza $record;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read
|
* Read
|
||||||
*
|
*
|
||||||
@@ -57,7 +64,7 @@ trait record
|
|||||||
offset: 0
|
offset: 0
|
||||||
)[0] ?? false;
|
)[0] ?? false;
|
||||||
|
|
||||||
if ($record instanceof record) {
|
if ($record instanceof baza) {
|
||||||
// Initialized the record
|
// Initialized the record
|
||||||
|
|
||||||
// Exit (success)
|
// Exit (success)
|
||||||
@@ -79,9 +86,9 @@ trait record
|
|||||||
{
|
{
|
||||||
// Writing into the database
|
// Writing into the database
|
||||||
$record = $this->database->read(
|
$record = $this->database->read(
|
||||||
filter: fn(record $record) => $record->identifier === $this->record->identifier,
|
filter: fn(baza $record) => $record->identifier === $this->record->identifier,
|
||||||
update: function (record &$record) {
|
update: function (baza &$record) {
|
||||||
$this->record->updated = mirzaev::timestamp();
|
$this->record->updated = svoboda::timestamp();
|
||||||
$record = $this->record;
|
$record = $this->record;
|
||||||
},
|
},
|
||||||
amount: 1,
|
amount: 1,
|
||||||
|
|||||||
Reference in New Issue
Block a user