This commit is contained in:
Arsen Mirzaev Tatyano-Muradovich 2025-02-04 22:09:37 +07:00
parent 6937c70c9c
commit 260be006ae
2 changed files with 95 additions and 65 deletions

View File

@ -368,8 +368,13 @@ class database
*
* @return array|null Readed records
*/
public function read(?callable $filter = null, ?callable $update = null, bool $delete = false, int $amount = 1, int $offset = 0): ?array
{
public function read(
?callable $filter = null,
?callable $update = null,
bool $delete = false,
int $amount = 1,
int $offset = 0
): ?array {
// Opening the database file
$file = fopen($this->database, 'c+b');
@ -485,6 +490,16 @@ class database
return null;
}
/**
* Count
*
* @return int Amount of records
*/
public function count(): int{
// Exit (success)
return $this->length > 0 && file_exists($this->database) ? filesize($this->database) / $this->length : 0;
}
/**
* Backups
*

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
use mirzaev\baza\database,
mirzaev\baza\record,
mirzaev\baza\column,
@ -7,11 +9,24 @@ use mirzaev\baza\database,
mirzaev\baza\enumerations\type;
// Initializing path to the composer loader file (main project)
$autoload = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
$autoload =
__DIR__ . DIRECTORY_SEPARATOR .
'..' . DIRECTORY_SEPARATOR .
'..' . DIRECTORY_SEPARATOR .
'..' . DIRECTORY_SEPARATOR .
'vendor' . DIRECTORY_SEPARATOR .
'autoload.php';
// Reinitializing path to the composer loaded file (depencendy project)
if (!file_exists($autoload))
$autoload = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'autoload.php';
$autoload =
__DIR__ . DIRECTORY_SEPARATOR .
'..' . DIRECTORY_SEPARATOR .
'..' . DIRECTORY_SEPARATOR .
'..' . DIRECTORY_SEPARATOR .
'..' . DIRECTORY_SEPARATOR .
'..' . DIRECTORY_SEPARATOR .
'autoload.php';
// Importing files of thr project and dependencies
require($autoload);