Added in transaction support

This commit is contained in:
jengo 2001-05-24 07:54:33 +00:00
parent dcbcb567a0
commit 33aa5de6f5
2 changed files with 72 additions and 21 deletions

View File

@ -198,6 +198,22 @@ class db {
return 1;
}
function transaction_begin()
{
return True;
}
function transaction_commit()
{
return True;
}
function transaction_abort()
{
return True;
}
/* public: table locking */
function lock($table, $mode="write") {
$this->connect();

View File

@ -125,29 +125,64 @@ class db {
return $stat;
}
function seek($pos) {
$this->Row = $pos;
}
function seek($pos)
{
$this->Row = $pos;
}
function lock($table, $mode = "write") {
$result = pg_Exec($this->Link_ID, "begin work");
if ($mode == "write") {
if (is_array($table)) {
while ($t = each($table)) {
$result = pg_Exec($this->Link_ID,"lock table $t[1] in share mode");
}
} else {
$result = pg_Exec($this->Link_ID, "lock table $table in share mode");
}
} else {
$result = 1;
}
return $result;
}
function transaction_begin()
{
return pg_Exec($this->Link_ID,'begin');
}
function unlock() {
return pg_Exec($this->Link_ID, "commit work");
}
function transaction_commit()
{
if (! $this->Errno)
{
return pg_Exec($this->Link_ID,'commit');
}
else
{
return False;
}
}
function transaction_abort()
{
return pg_Exec($this->Link_ID,'rollback');
}
function lock($table, $mode = 'write')
{
$result = $this->transaction_begin();
if ($mode == 'write')
{
if (is_array($table))
{
while ($t = each($table))
{
$result = pg_Exec($this->Link_ID,'lock table ' . $t[1] . ' in share mode');
}
}
else
{
$result = pg_Exec($this->Link_ID, "lock table $table in share mode");
}
}
else
{
$result = 1;
}
return $result;
}
function unlock()
{
return $this->transaction_commit();
}
/* public: sequence numbers */