Compare commits

..

No commits in common. "stable" and "3.2.0" have entirely different histories.

2 changed files with 65 additions and 104 deletions
mirzaev/baza

View File

@ -368,13 +368,8 @@ 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');
@ -465,9 +460,9 @@ class database
--$amount;
}
}
} else {
} else {
// The record contains only empty values
}
}
} catch (exception_logic | exception_invalid_argument | exception_domain $exception) {
// Writing into the buffer of failed to reading records
@ -490,25 +485,6 @@ class database
return null;
}
/**
* Count
*
* @throws exception_runtime If the database is corrupted (counting result is float)
*
* @return int Amount of records
*/
public function count(): int
{
// Deleting the database file cache
clearstatcache(true, $this->database);
// Counting
$amount = $this->length > 0 && file_exists($this->database) ? filesize($this->database) / $this->length : 0;
// Exit (success/fail)
return is_int($amount) ? $amount : throw new exception_runtime('The database is corrupted');
}
/**
* Backups
*

View File

@ -1,7 +1,5 @@
<?php
declare(strict_types=1);
use mirzaev\baza\database,
mirzaev\baza\record,
mirzaev\baza\column,
@ -9,24 +7,11 @@ 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);