ajout dbAll, dbOne

This commit is contained in:
Jephté Clain 2025-06-25 17:14:19 +04:00
parent e90d5cf883
commit 792e1ff965
2 changed files with 29 additions and 4 deletions

View File

@ -182,11 +182,27 @@ class Capacitor implements ITransactor {
return $this->storage->_delete($this->channel, $filter, $func, $args); return $this->storage->_delete($this->channel, $filter, $func, $args);
} }
function dbUpdate(array $update) { function dbAll(array $query, ?array $params=null): iterable {
$primaryKeys = $this->channel->getPrimaryKeys();
return $this->storage->db()->all(cl::merge([
"select",
"from" => $this->getTableName(),
], $query), $params, $primaryKeys);
}
function dbOne(array $query, ?array $params=null): ?array {
return $this->storage->db()->one(cl::merge([
"select",
"from" => $this->getTableName(),
], $query), $params);
}
/** @return int|false */
function dbUpdate(array $query, ?array $params=null) {
return $this->storage->db()->exec(cl::merge([ return $this->storage->db()->exec(cl::merge([
"update", "update",
"table" => $this->getTableName(), "table" => $this->getTableName(),
], $update)); ], $query), $params);
} }
function close(): void { function close(): void {

View File

@ -508,8 +508,17 @@ class CapacitorChannel implements ITransactor {
return $this->capacitor->delete($filter, $func, $args); return $this->capacitor->delete($filter, $func, $args);
} }
function dbUpdate(array $update) { function dbAll(array $query, ?array $params=null): iterable {
return $this->capacitor->dbUpdate($update); return $this->capacitor->dbAll($query, $params);
}
function dbOne(array $query, ?array $params=null): ?array {
return $this->capacitor->dbOne($query, $params);
}
/** @return int|false */
function dbUpdate(array $query, ?array $params=null) {
return $this->capacitor->dbUpdate($query, $params);
} }
function close(): void { function close(): void {