modifs.mineures sans commentaires
This commit is contained in:
parent
f3af19406b
commit
2f6c120758
|
@ -150,9 +150,9 @@ class Capacitor implements ITransactor {
|
|||
return $this->storage->_all($this->channel, $filter);
|
||||
}
|
||||
|
||||
function each($filter, $func=null, ?array $args=null): int {
|
||||
function each($filter, $func=null, ?array $args=null, ?int &$updated=null): int {
|
||||
$this->beginTransaction();
|
||||
return $this->storage->_each($this->channel, $filter, $func, $args);
|
||||
return $this->storage->_each($this->channel, $filter, $func, $args, $updated);
|
||||
}
|
||||
|
||||
function delete($filter, $func=null, ?array $args=null): int {
|
||||
|
|
|
@ -438,9 +438,10 @@ EOT;
|
|||
* si la fonction retourne un tableau, il est utilisé pour mettre à jour la
|
||||
* ligne
|
||||
*
|
||||
* @param int $updated reçoit le nombre de lignes mises à jour
|
||||
* @return int le nombre de lignes parcourues
|
||||
*/
|
||||
function _each(CapacitorChannel $channel, $filter, $func, ?array $args): int {
|
||||
function _each(CapacitorChannel $channel, $filter, $func, ?array $args, ?int &$updated=null): int {
|
||||
$this->_create($channel);
|
||||
if ($func === null) $func = "->onEach";
|
||||
func::ensure_func($func, $channel, $args);
|
||||
|
@ -449,6 +450,7 @@ EOT;
|
|||
$tableName = $channel->getTableName();
|
||||
$manageTransactions = $channel->isManageTransactions();
|
||||
$count = 0;
|
||||
$updated = 0;
|
||||
if ($manageTransactions) {
|
||||
$commited = false;
|
||||
$db->beginTransaction();
|
||||
|
@ -463,7 +465,7 @@ EOT;
|
|||
if (!array_key_exists("modified_", $updates)) {
|
||||
$updates["modified_"] = date("Y-m-d H:i:s");
|
||||
}
|
||||
$db->exec([
|
||||
$updated += $db->exec([
|
||||
"update",
|
||||
"table" => $tableName,
|
||||
"values" => $this->serialize($channel, $updates),
|
||||
|
@ -490,8 +492,8 @@ EOT;
|
|||
}
|
||||
}
|
||||
|
||||
function each(?string $channel, $filter, $func=null, ?array $args=null): int {
|
||||
return $this->_each($this->getChannel($channel), $filter, $func, $args);
|
||||
function each(?string $channel, $filter, $func=null, ?array $args=null, ?int &$updated=null): int {
|
||||
return $this->_each($this->getChannel($channel), $filter, $func, $args, $updated);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -39,6 +39,16 @@ class Sqlite implements IDatabase {
|
|||
$sqlite->db->enableExceptions(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @var int temps maximum à attendre que la base soit accessible si elle est
|
||||
* verrouillée
|
||||
*/
|
||||
const BUSY_TIMEOUT = 30 * 1000;
|
||||
|
||||
static function config_busyTimeout(self $sqlite): void {
|
||||
$sqlite->db->busyTimeout(static::BUSY_TIMEOUT);
|
||||
}
|
||||
|
||||
static function config_enableWalIfAllowed(self $sqlite): void {
|
||||
if ($sqlite->isWalAllowed()) {
|
||||
$sqlite->db->exec("PRAGMA journal_mode=WAL");
|
||||
|
@ -49,6 +59,7 @@ class Sqlite implements IDatabase {
|
|||
|
||||
const CONFIG = [
|
||||
[self::class, "config_enableExceptions"],
|
||||
[self::class, "config_busyTimeout"],
|
||||
[self::class, "config_enableWalIfAllowed"],
|
||||
];
|
||||
|
||||
|
|
Loading…
Reference in New Issue