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.

45 lines
974 B

<?php
declare(strict_types=1);
namespace JKingWeb\Arsse\Db;
class Transaction {
protected $index;
protected $pending = false;
protected $drv;
function __construct(Driver $drv) {
$this->index = $drv->savepointCreate();
$this->drv = $drv;
$this->pending = true;
}
function __destruct() {
if($this->pending) {
try {
$this->drv->savepointUndo($this->index);
} catch(\Throwable $e) {
// do nothing
}
}
}
function commit(): bool {
$out = $this->drv->savepointRelease($this->index);
$this->pending = false;
return $out;
}
function rollback(): bool {
$out = $this->drv->savepointUndo($this->index);
$this->pending = false;
return $out;
}
function getIndex(): int {
return $this->index;
}
function isPending(): bool {
return $this->pending;
}
}