mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-12 06:18:52 +00:00
Put transaction support into oracle DBAL
git-svn-id: file:///svn/phpbb/trunk@1033 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
2ce073c4ef
commit
4e18945c0c
1 changed files with 26 additions and 9 deletions
|
@ -29,9 +29,10 @@ class sql_db
|
||||||
|
|
||||||
var $db_connect_id;
|
var $db_connect_id;
|
||||||
var $query_result;
|
var $query_result;
|
||||||
|
var $in_transaction = 0;
|
||||||
var $row;
|
var $row;
|
||||||
var $num_queries = 0;
|
var $num_queries = 0;
|
||||||
var $last_query = "";
|
var $last_query_text = "";
|
||||||
|
|
||||||
//
|
//
|
||||||
// Constructor
|
// Constructor
|
||||||
|
@ -69,6 +70,12 @@ class sql_db
|
||||||
{
|
{
|
||||||
if($this->db_connect_id)
|
if($this->db_connect_id)
|
||||||
{
|
{
|
||||||
|
// Commit outstanding transactions
|
||||||
|
if($this->in_transaction)
|
||||||
|
{
|
||||||
|
OCICommit($this->db_connect_id);
|
||||||
|
}
|
||||||
|
|
||||||
if($this->query_result)
|
if($this->query_result)
|
||||||
{
|
{
|
||||||
@OCIFreeStatement($this->query_result);
|
@OCIFreeStatement($this->query_result);
|
||||||
|
@ -117,10 +124,16 @@ class sql_db
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->query_result = @OCIParse($this->db_connect_id, $query);
|
$this->query_result = @OCIParse($this->db_connect_id, $query);
|
||||||
$success = @OCIExecute($this->query_result);
|
$success = @OCIExecute($this->query_result, OCI_DEFAULT);
|
||||||
}
|
}
|
||||||
if($success)
|
if($success)
|
||||||
{
|
{
|
||||||
|
if($transaction == END_TRANSACTION)
|
||||||
|
{
|
||||||
|
OCICommit($this->db_connect_id);
|
||||||
|
$this->in_transaction = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
unset($this->row[$this->query_result]);
|
unset($this->row[$this->query_result]);
|
||||||
unset($this->rowset[$this->query_result]);
|
unset($this->rowset[$this->query_result]);
|
||||||
$this->last_query_text[$this->query_result] = $query;
|
$this->last_query_text[$this->query_result] = $query;
|
||||||
|
@ -129,6 +142,10 @@ class sql_db
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if($this->in_transaction)
|
||||||
|
{
|
||||||
|
OCIRollback($this->db_connect_id);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -147,7 +164,7 @@ class sql_db
|
||||||
$result = @OCIFetchStatement($query_id, $this->rowset);
|
$result = @OCIFetchStatement($query_id, $this->rowset);
|
||||||
// OCIFetchStatment kills our query result so we have to execute the statment again
|
// OCIFetchStatment kills our query result so we have to execute the statment again
|
||||||
// if we ever want to use the query_id again.
|
// if we ever want to use the query_id again.
|
||||||
@OCIExecute($query_id);
|
@OCIExecute($query_id, OCI_DEFAULT);
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -273,7 +290,7 @@ class sql_db
|
||||||
if($query_id)
|
if($query_id)
|
||||||
{
|
{
|
||||||
$rows = @OCIFetchStatement($query_id, $results);
|
$rows = @OCIFetchStatement($query_id, $results);
|
||||||
@OCIExecute($query_id);
|
@OCIExecute($query_id, OCI_DEFAULT);
|
||||||
for($i = 0; $i <= $rows; $i++)
|
for($i = 0; $i <= $rows; $i++)
|
||||||
{
|
{
|
||||||
@OCIFetchInto($query_id, $tmp_result, OCI_ASSOC+OCI_RETURN_NULLS);
|
@OCIFetchInto($query_id, $tmp_result, OCI_ASSOC+OCI_RETURN_NULLS);
|
||||||
|
@ -303,7 +320,7 @@ class sql_db
|
||||||
if($rownum > -1)
|
if($rownum > -1)
|
||||||
{
|
{
|
||||||
// Reset the internal rownum pointer.
|
// Reset the internal rownum pointer.
|
||||||
@OCIExecute($query_id);
|
@OCIExecute($query_id, OCI_DEFAULT);
|
||||||
for($i = 0; $i < $rownum; $i++)
|
for($i = 0; $i < $rownum; $i++)
|
||||||
{
|
{
|
||||||
// Move the interal pointer to the row we want
|
// Move the interal pointer to the row we want
|
||||||
|
@ -333,7 +350,7 @@ class sql_db
|
||||||
}
|
}
|
||||||
if($query_id)
|
if($query_id)
|
||||||
{
|
{
|
||||||
@OCIExecute($query_id);
|
@OCIExecute($query_id, OCI_DEFAULT);
|
||||||
for($i = 0; $i < $rownum; $i++)
|
for($i = 0; $i < $rownum; $i++)
|
||||||
{
|
{
|
||||||
@OCIFetch($query_id);
|
@OCIFetch($query_id);
|
||||||
|
@ -357,8 +374,8 @@ class sql_db
|
||||||
if( eregi("^(INSERT{1}|^INSERT INTO{1})[[:space:]][\"]?([a-zA-Z0-9\_\-]+)[\"]?", $this->last_query_text[$query_id], $tablename))
|
if( eregi("^(INSERT{1}|^INSERT INTO{1})[[:space:]][\"]?([a-zA-Z0-9\_\-]+)[\"]?", $this->last_query_text[$query_id], $tablename))
|
||||||
{
|
{
|
||||||
$query = "SELECT ".$tablename[2]."_id_seq.currval FROM DUAL";
|
$query = "SELECT ".$tablename[2]."_id_seq.currval FROM DUAL";
|
||||||
$stmt = OCIParse($this->db_connect_id, $query);
|
$stmt = @OCIParse($this->db_connect_id, $query);
|
||||||
OCIExecute($stmt);
|
@OCIExecute($stmt,OCI_DEFAULT );
|
||||||
$temp_result = @OCIFetchInto($stmt, $temp_result, OCI_ASSOC+OCI_RETURN_NULLS);
|
$temp_result = @OCIFetchInto($stmt, $temp_result, OCI_ASSOC+OCI_RETURN_NULLS);
|
||||||
if($temp_result)
|
if($temp_result)
|
||||||
{
|
{
|
||||||
|
@ -392,7 +409,7 @@ class sql_db
|
||||||
{
|
{
|
||||||
$query = "SELECT ".$tablename[2]."_id_seq.CURRVAL FROM DUAL";
|
$query = "SELECT ".$tablename[2]."_id_seq.CURRVAL FROM DUAL";
|
||||||
$temp_q_id = @OCIParse($this->db_connect_id, $query);
|
$temp_q_id = @OCIParse($this->db_connect_id, $query);
|
||||||
@OCIExecute($temp_q_id);
|
@OCIExecute($temp_q_id, OCI_DEFAULT);
|
||||||
@OCIFetchInto($temp_q_id, $temp_result, OCI_ASSOC+OCI_RETURN_NULLS);
|
@OCIFetchInto($temp_q_id, $temp_result, OCI_ASSOC+OCI_RETURN_NULLS);
|
||||||
|
|
||||||
if($temp_result)
|
if($temp_result)
|
||||||
|
|
Loading…
Add table
Reference in a new issue