The clean & modern RSS server that doesn't give you any crap.
https://thearsse.com/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.1 KiB
47 lines
1.1 KiB
<?php
|
|
declare(strict_types=1);
|
|
namespace JKingWeb\NewsSync\Db;
|
|
|
|
Trait Common {
|
|
protected $transDepth;
|
|
|
|
public function begin(): bool {
|
|
if($this->transDepth==0) {
|
|
$this->exec("BEGIN TRANSACTION");
|
|
} else{
|
|
$this->exec("SAVEPOINT newssync_".$this->transDepth);
|
|
}
|
|
$this->transDepth += 1;
|
|
return true;
|
|
}
|
|
|
|
public function commit(bool $all = false): bool {
|
|
if($this->transDepth==0) return false;
|
|
if(!$all) {
|
|
$this->exec("RELEASE SAVEPOINT newssync_".$this->transDepth-1);
|
|
$this->transDepth -= 1;
|
|
} else {
|
|
$this->exec("COMMIT TRANSACTION");
|
|
$this->transDepth = 0;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public function rollback(bool $all = false): bool {
|
|
if($this->transDepth==0) return false;
|
|
if(!$all) {
|
|
$this->exec("ROLLBACK TRANSACTION TO SAVEPOINT newssync_".$this->transDepth-1);
|
|
$this->transDepth -= 1;
|
|
if($this->transDepth==0) $this->exec("ROLLBACK TRANSACTION");
|
|
} else {
|
|
$this->exec("ROLLBACK TRANSACTION");
|
|
$this->transDepth = 0;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public function prepare(string $query, string ...$paramType): Statement {
|
|
return $this->prepareArray($query, $paramType);
|
|
}
|
|
|
|
}
|