What it is :
What it is not :
When to use :
symfony/lock
)Implemented files formats :
There is not a lot of documentation because I did this project for me and I guess a few examples and reading the code should be enough for developers.
Examples are the best documentation you will find.
php$storage = new \Arnapou\PFDB\Storage\PhpFileStorage($somePath);
$database = new \Arnapou\PFDB\Database($storage);
$table = $database->getTable('vehicle');
$expr = $table->expr()->and(
$table->expr()->gt('price', 10000),
$table->expr()->match('model', '^C[0-9]+')
);
$iterator = $table->find($expr)
->sort('constructor' , ['model' , 'DESC'])
->limit(0, 50);
foreach($iterator as $key => $row) {
// do whatever you want
}
phpclass IsUppercaseExpr implements \Arnapou\PFDB\Query\Helper\Expr\ExprInterface {
private $field;
public function construct(string $field)
{
$this->field = $field;
}
public function invoke(array $row, $key = null): bool
{
if(!isset($row[$this->field]) {
return false;
}
$testedValue = (string)$row[$this->field];
return $testedValue === strtoupper($testedValue);
}
}
Use :
php$storage = new \Arnapou\PFDB\Storage\PhpFileStorage($somePath);
$database = new \Arnapou\PFDB\Database($storage);
$table = $database->getTable('vehicle');
$expr = new IsUppercaseExpr('model');
foreach($table->find($expr) as $key => $row) {
// do whatever you want
}
if you just want to select, filter, sort, limit, group, order any iterator
php$data = [
['name' => 'John', 'age' => 20],
['name' => 'Edith', 'age' => 25],
['name' => 'Steve', 'age' => 30],
['name' => 'Matthew', 'age' => 22],
);
$query = (new \Arnapou\PFDB\Query\Query())
->from(new \ArrayIterator($data))
->where($query->expr()->gt('age', 24));
foreach($query as $key => $row) {
// do whatever you want
}
Easy : extends or implements your own storage and use it to load/store/delete data.
Look at the existing storages and write your own.