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);
|
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();
|
$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 {
|
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
|
* si la fonction retourne un tableau, il est utilisé pour mettre à jour la
|
||||||
* ligne
|
* ligne
|
||||||
*
|
*
|
||||||
|
* @param int $updated reçoit le nombre de lignes mises à jour
|
||||||
* @return int le nombre de lignes parcourues
|
* @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);
|
$this->_create($channel);
|
||||||
if ($func === null) $func = "->onEach";
|
if ($func === null) $func = "->onEach";
|
||||||
func::ensure_func($func, $channel, $args);
|
func::ensure_func($func, $channel, $args);
|
||||||
|
@ -449,6 +450,7 @@ EOT;
|
||||||
$tableName = $channel->getTableName();
|
$tableName = $channel->getTableName();
|
||||||
$manageTransactions = $channel->isManageTransactions();
|
$manageTransactions = $channel->isManageTransactions();
|
||||||
$count = 0;
|
$count = 0;
|
||||||
|
$updated = 0;
|
||||||
if ($manageTransactions) {
|
if ($manageTransactions) {
|
||||||
$commited = false;
|
$commited = false;
|
||||||
$db->beginTransaction();
|
$db->beginTransaction();
|
||||||
|
@ -463,7 +465,7 @@ EOT;
|
||||||
if (!array_key_exists("modified_", $updates)) {
|
if (!array_key_exists("modified_", $updates)) {
|
||||||
$updates["modified_"] = date("Y-m-d H:i:s");
|
$updates["modified_"] = date("Y-m-d H:i:s");
|
||||||
}
|
}
|
||||||
$db->exec([
|
$updated += $db->exec([
|
||||||
"update",
|
"update",
|
||||||
"table" => $tableName,
|
"table" => $tableName,
|
||||||
"values" => $this->serialize($channel, $updates),
|
"values" => $this->serialize($channel, $updates),
|
||||||
|
@ -490,8 +492,8 @@ EOT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function each(?string $channel, $filter, $func=null, ?array $args=null): int {
|
function each(?string $channel, $filter, $func=null, ?array $args=null, ?int &$updated=null): int {
|
||||||
return $this->_each($this->getChannel($channel), $filter, $func, $args);
|
return $this->_each($this->getChannel($channel), $filter, $func, $args, $updated);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -39,6 +39,16 @@ class Sqlite implements IDatabase {
|
||||||
$sqlite->db->enableExceptions(true);
|
$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 {
|
static function config_enableWalIfAllowed(self $sqlite): void {
|
||||||
if ($sqlite->isWalAllowed()) {
|
if ($sqlite->isWalAllowed()) {
|
||||||
$sqlite->db->exec("PRAGMA journal_mode=WAL");
|
$sqlite->db->exec("PRAGMA journal_mode=WAL");
|
||||||
|
@ -49,6 +59,7 @@ class Sqlite implements IDatabase {
|
||||||
|
|
||||||
const CONFIG = [
|
const CONFIG = [
|
||||||
[self::class, "config_enableExceptions"],
|
[self::class, "config_enableExceptions"],
|
||||||
|
[self::class, "config_busyTimeout"],
|
||||||
[self::class, "config_enableWalIfAllowed"],
|
[self::class, "config_enableWalIfAllowed"],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue