aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/db/postgres7.php
diff options
context:
space:
mode:
authorPaul S. Owen <psotfx@users.sourceforge.net>2001-07-03 22:47:26 +0000
committerPaul S. Owen <psotfx@users.sourceforge.net>2001-07-03 22:47:26 +0000
commit356f845abc4ed17322c7afc904ba4a67718327d2 (patch)
tree0d2d54971f32ce6b8698802f739982a6db5c11ea /phpBB/db/postgres7.php
parent8baa46e2856552b68938c1e6e8ad9e355bf7f3e9 (diff)
downloadforums-356f845abc4ed17322c7afc904ba4a67718327d2.tar
forums-356f845abc4ed17322c7afc904ba4a67718327d2.tar.gz
forums-356f845abc4ed17322c7afc904ba4a67718327d2.tar.bz2
forums-356f845abc4ed17322c7afc904ba4a67718327d2.tar.xz
forums-356f845abc4ed17322c7afc904ba4a67718327d2.zip
Transaction capability moved to DB classes
git-svn-id: file:///svn/phpbb/trunk@546 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/db/postgres7.php')
-rw-r--r--phpBB/db/postgres7.php43
1 files changed, 40 insertions, 3 deletions
diff --git a/phpBB/db/postgres7.php b/phpBB/db/postgres7.php
index 08f065f0e7..981439cc10 100644
--- a/phpBB/db/postgres7.php
+++ b/phpBB/db/postgres7.php
@@ -28,7 +28,8 @@ class sql_db
{
var $db_connect_id;
- var $query_result;
+ var $query_result;
+ var $in_transaction = 0;
var $row;
var $rownum = array();
@@ -115,7 +116,7 @@ class sql_db
//
// Query method
//
- function sql_query($query="")
+ function sql_query($query = "", $transaction = FALSE)
{
// Remove any pre-existing queries
unset($this->query_result);
@@ -123,11 +124,32 @@ class sql_db
{
$query = preg_replace("/LIMIT ([0-9]+),([ 0-9]+)/", "LIMIT \\2, \\1", $query);
+ if($transaction == BEGIN_TRANSACTION)
+ {
+ $result = @pg_exec($this->db_connect_id, "BEGIN");
+ if(!$result)
+ {
+ return false;
+ }
+ }
+
$this->query_result = @pg_exec($this->db_connect_id, $query);
if($this->query_result)
{
+ if($transaction == END_TRANSACTION)
+ {
+ $result = @pg_exec($this->db_connect_id, "COMMIT");
+ if(!$result)
+ {
+ @pg_exec($this->db_connect_id, "ROLLBACK");
+ return false;
+ }
+ $this->in_transaction = FALSE;
+ }
+
$this->last_query_text[$this->query_result] = $query;
$this->rownum[$this->query_result] = 0;
+
unset($this->row[$this->query_result]);
unset($this->rowset[$this->query_result]);
@@ -135,11 +157,26 @@ class sql_db
}
else
{
+ if($this->in_transaction)
+ {
+ @pg_exec($this->db_connect_id, "ROLLBACK");
+ }
return false;
}
}
else
{
+ if($transaction == END_TRANSACTION)
+ {
+ $result = @pg_exec($this->db_connect_id, "COMMIT");
+ if(!$result)
+ {
+ @pg_exec($this->db_connect_id, "ROLLBACK");
+ return false;
+ }
+ $this->in_transaction = FALSE;
+ }
+
return false;
}
}
@@ -391,4 +428,4 @@ class sql_db
} // if ... defined
-?>
+?> \ No newline at end of file