|
From: Paul S. O. <ps...@us...> - 2002-01-01 14:35:36
|
Update of /cvsroot/phpbb/phpBB2/db
In directory usw-pr-cvs1:/tmp/cvs-serv21741/db
Modified Files:
postgres7.php
Log Message:
Fix for bug #497093 + other updates
Index: postgres7.php
===================================================================
RCS file: /cvsroot/phpbb/phpBB2/db/postgres7.php,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -r1.15 -r1.16
*** postgres7.php 2001/12/31 20:36:46 1.15
--- postgres7.php 2002/01/01 14:35:33 1.16
***************
*** 38,63 ****
// Constructor
//
! function sql_db($sqlserver, $sqluser, $sqlpassword, $database, $persistency=true)
{
-
$this->connect_string = "";
! if($sqluser)
{
$this->connect_string .= "user=$sqluser ";
}
! if($sqlpassword)
{
$this->connect_string .= "password=$sqlpassword ";
}
! if($sqlserver)
{
! if(ereg(":",$sqlserver))
{
! list($sqlserver,$sqlport) = split(":",$sqlserver);
$this->connect_string .= "host=$sqlserver port=$sqlport ";
}
else
{
! if($sqlserver != "localhost")
{
$this->connect_string .= "host=$sqlserver ";
--- 38,65 ----
// Constructor
//
! function sql_db($sqlserver, $sqluser, $sqlpassword, $database, $persistency = true)
{
$this->connect_string = "";
!
! if( $sqluser )
{
$this->connect_string .= "user=$sqluser ";
}
!
! if( $sqlpassword )
{
$this->connect_string .= "password=$sqlpassword ";
}
!
! if( $sqlserver )
{
! if( ereg(":", $sqlserver) )
{
! list($sqlserver, $sqlport) = split(":", $sqlserver);
$this->connect_string .= "host=$sqlserver port=$sqlport ";
}
else
{
! if( $sqlserver != "localhost" )
{
$this->connect_string .= "host=$sqlserver ";
***************
*** 65,97 ****
}
}
! if($database)
{
$this->dbname = $database;
! $make_connect = $this->connect_string . "dbname=$database";
}
- else
- {
- $make_connect = $this->connect_string;
- }
$this->persistency = $persistency;
- if($this->persistency)
- {
- $this->db_connect_id = @pg_pconnect($make_connect);
- }
- else
- {
- $this->db_connect_id = @pg_connect($make_connect);
- }
! if($this->db_connect_id)
! {
! return $this->db_connect_id;
! }
! else
! {
! return false;
! }
}
//
// Other base methods
--- 67,84 ----
}
}
!
! if( $database )
{
$this->dbname = $database;
! $this->connect_string .= "dbname=$database";
}
$this->persistency = $persistency;
! $this->db_connect_id = ( $this->persistency ) ? pg_pconnect($this->connect_string) : pg_connect($this->connect_string);
!
! return ( $this->db_connect_id ) ? $this->db_connect_id : false;
}
+
//
// Other base methods
***************
*** 99,103 ****
function sql_close()
{
! if($this->db_connect_id)
{
//
--- 86,90 ----
function sql_close()
{
! if( $this->db_connect_id )
{
//
***************
*** 109,118 ****
}
! if($this->query_result)
{
@pg_freeresult($this->query_result);
}
! $result = @pg_close($this->db_connect_id);
! return $result;
}
else
--- 96,105 ----
}
! if( $this->query_result )
{
@pg_freeresult($this->query_result);
}
!
! return @pg_close($this->db_connect_id);
}
else
***************
*** 126,134 ****
// Query method
//
! function sql_query($query = "", $transaction = FALSE)
{
// Remove any pre-existing queries
unset($this->query_result);
! if($query != "")
{
$this->num_queries++;
--- 113,123 ----
// Query method
//
! function sql_query($query = "", $transaction = false)
{
+ //
// Remove any pre-existing queries
+ //
unset($this->query_result);
! if( $query != "" )
{
$this->num_queries++;
***************
*** 136,143 ****
$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;
--- 125,132 ----
$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;
***************
*** 147,156 ****
$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");
--- 136,145 ----
$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");
***************
*** 170,174 ****
else
{
! if($this->in_transaction)
{
@pg_exec($this->db_connect_id, "ROLLBACK");
--- 159,163 ----
else
{
! if( $this->in_transaction )
{
@pg_exec($this->db_connect_id, "ROLLBACK");
***************
*** 181,188 ****
else
{
! if($transaction == END_TRANSACTION)
{
$result = @pg_exec($this->db_connect_id, "COMMIT");
! if(!$result)
{
@pg_exec($this->db_connect_id, "ROLLBACK");
--- 170,177 ----
else
{
! if( $transaction == END_TRANSACTION )
{
$result = @pg_exec($this->db_connect_id, "COMMIT");
! if( !$result )
{
@pg_exec($this->db_connect_id, "ROLLBACK");
***************
*** 195,198 ****
--- 184,188 ----
}
}
+
//
// Other query methods
***************
*** 200,312 ****
function sql_numrows($query_id = 0)
{
! if(!$query_id)
{
$query_id = $this->query_result;
- }
- if($query_id)
- {
- $result = @pg_numrows($query_id);
- return $result;
- }
- else
- {
- return false;
}
! }
! function sql_affectedrows($query_id = 0)
! {
! if(!$query_id)
! {
! $query_id = $this->query_result;
! }
! if($query_id)
! {
! $result = @pg_cmdtuples($query_id);
! return $result;
! }
! else
! {
! return false;
! }
}
function sql_numfields($query_id = 0)
{
! if(!$query_id)
{
$query_id = $this->query_result;
}
! if($query_id)
! {
! $result = @pg_numfields($query_id);
! return $result;
! }
! else
! {
! return false;
! }
}
function sql_fieldname($offset, $query_id = 0)
{
! if(!$query_id)
{
$query_id = $this->query_result;
- }
- if($query_id)
- {
- $result = @pg_fieldname($query_id, $offset);
- return $result;
- }
- else
- {
- return false;
}
}
function sql_fieldtype($offset, $query_id = 0)
{
! if(!$query_id)
{
$query_id = $this->query_result;
}
! if($query_id)
! {
! $result = @pg_fieldtype($query_id, $offset);
! return $result;
! }
! else
! {
! return false;
! }
}
function sql_fetchrow($query_id = 0)
{
! if(!$query_id)
{
$query_id = $this->query_result;
}
if($query_id)
{
$this->row = @pg_fetch_array($query_id, $this->rownum[$query_id]);
! if($this->row)
{
$this->rownum[$query_id]++;
return $this->row;
}
- else
- {
- return false;
- }
}
! else
! {
! return false;
! }
}
function sql_fetchrowset($query_id = 0)
{
! if(!$query_id)
{
$query_id = $this->query_result;
}
! if($query_id)
{
unset($this->rowset[$query_id]);
--- 190,260 ----
function sql_numrows($query_id = 0)
{
! if( !$query_id )
{
$query_id = $this->query_result;
}
!
! return ( $query_id ) ? @pg_numrows($query_id) : false;
}
+
function sql_numfields($query_id = 0)
{
! if( !$query_id )
{
$query_id = $this->query_result;
}
!
! return ( $query_id ) ? @pg_numfields($query_id) : false;
}
+
function sql_fieldname($offset, $query_id = 0)
{
! if( !$query_id )
{
$query_id = $this->query_result;
}
+
+ return ( $query_id ) ? @pg_fieldname($query_id, $offset) : false;
}
+
function sql_fieldtype($offset, $query_id = 0)
{
! if( !$query_id )
{
$query_id = $this->query_result;
}
!
! return ( $query_id ) ? @pg_fieldtype($query_id, $offset) : false;
}
+
function sql_fetchrow($query_id = 0)
{
! if( !$query_id )
{
$query_id = $this->query_result;
}
+
if($query_id)
{
$this->row = @pg_fetch_array($query_id, $this->rownum[$query_id]);
!
! if( $this->row )
{
$this->rownum[$query_id]++;
return $this->row;
}
}
!
! return false;
}
+
function sql_fetchrowset($query_id = 0)
{
! if( !$query_id )
{
$query_id = $this->query_result;
}
!
! if( $query_id )
{
unset($this->rowset[$query_id]);
***************
*** 314,338 ****
$this->rownum[$query_id] = 0;
! while($this->rowset = @pg_fetch_array($query_id, $this->rownum[$query_id], PGSQL_ASSOC))
{
$result[] = $this->rowset;
$this->rownum[$query_id]++;
}
return $result;
- }
- else
- {
- return false;
}
}
function sql_fetchfield($field, $row_offset=-1, $query_id = 0)
{
! if(!$query_id)
{
$query_id = $this->query_result;
}
! if($query_id)
{
! if($row_offset != -1)
{
$this->row = @pg_fetch_array($query_id, $row_offset, PGSQL_ASSOC);
--- 262,287 ----
$this->rownum[$query_id] = 0;
! while( $this->rowset = @pg_fetch_array($query_id, $this->rownum[$query_id], PGSQL_ASSOC) )
{
$result[] = $this->rowset;
$this->rownum[$query_id]++;
}
+
return $result;
}
+
+ return false;
}
+
function sql_fetchfield($field, $row_offset=-1, $query_id = 0)
{
! if( !$query_id )
{
$query_id = $this->query_result;
}
!
! if( $query_id )
{
! if( $row_offset != -1 )
{
$this->row = @pg_fetch_array($query_id, $row_offset, PGSQL_ASSOC);
***************
*** 340,344 ****
else
{
! if($this->rownum[$query_id])
{
$this->row = @pg_fetch_array($query_id, $this->rownum[$query_id]-1, PGSQL_ASSOC);
--- 289,293 ----
else
{
! if( $this->rownum[$query_id] )
{
$this->row = @pg_fetch_array($query_id, $this->rownum[$query_id]-1, PGSQL_ASSOC);
***************
*** 347,351 ****
{
$this->row = @pg_fetch_array($query_id, $this->rownum[$query_id], PGSQL_ASSOC);
! if($this->row)
{
$this->rownum[$query_id]++;
--- 296,301 ----
{
$this->row = @pg_fetch_array($query_id, $this->rownum[$query_id], PGSQL_ASSOC);
!
! if( $this->row )
{
$this->rownum[$query_id]++;
***************
*** 353,371 ****
}
}
return $this->row[$field];
}
! else
! {
! return false;
! }
}
! function sql_rowseek($offset, $query_id = 0){
if(!$query_id)
{
$query_id = $this->query_result;
}
! if($query_id)
{
! if($offset>-1)
{
$this->rownum[$query_id] = $offset;
--- 303,324 ----
}
}
+
return $this->row[$field];
}
!
! return false;
}
!
! function sql_rowseek($offset, $query_id = 0)
! {
!
if(!$query_id)
{
$query_id = $this->query_result;
}
!
! if( $query_id )
{
! if( $offset > -1 )
{
$this->rownum[$query_id] = $offset;
***************
*** 376,395 ****
return false;
}
- }
- else
- {
- return false;
}
}
! function sql_nextid($query_id = 0)
{
! if(!$query_id)
! {
! $query_id = $this->query_result;
! }
if($query_id && $this->last_query_text[$query_id] != "")
{
!
! if( preg_match("/^INSERT[ ]+INTO[ ]+([a-z0-9\_\-]+)/is", $this->last_query_text[$query_id], $tablename) )
{
$query = "SELECT last_value
--- 329,344 ----
return false;
}
}
+
+ return false;
}
!
! function sql_nextid()
{
! $query_id = $this->query_result;
!
if($query_id && $this->last_query_text[$query_id] != "")
{
! if( preg_match("/^INSERT[\t\n ]+INTO[\t\n ]+([a-z0-9\_\-]+)/is", $this->last_query_text[$query_id], $tablename) )
{
$query = "SELECT last_value
***************
*** 402,445 ****
$temp_result = @pg_fetch_array($temp_q_id, 0, PGSQL_ASSOC);
! if($temp_result)
! {
! return $temp_result['last_value'];
! }
! else
! {
! return false;
! }
! }
! else
! {
! return false;
}
- }
- else
- {
- return false;
}
}
! function sql_freeresult($query_id = 0){
! if(!$query_id){
! $query_id = $this->query_result;
! }
! if($query_id)
{
! $result = @pg_freeresult($query_id);
! return $result;
}
! else
{
! return false;
}
}
function sql_error($query_id = 0)
{
! if(!$query_id){
$query_id = $this->query_result;
}
$result['message'] = @pg_errormessage($this->db_connect_id);
$result['code'] = -1;
return $result;
}
--- 351,392 ----
$temp_result = @pg_fetch_array($temp_q_id, 0, PGSQL_ASSOC);
!
! return ( $temp_result ) ? $temp_result['last_value'] : false;
}
}
+
+ return false;
}
!
! function sql_affectedrows($query_id = 0)
! {
! if( !$query_id )
{
! $query_id = $this->query_result;
}
!
! return ( $query_id ) ? @pg_cmdtuples($query_id) : false;
! }
!
! function sql_freeresult($query_id = 0)
! {
! if( !$query_id )
{
! $query_id = $this->query_result;
}
+
+ return ( $query_id ) ? @pg_freeresult($query_id) : false;
}
+
function sql_error($query_id = 0)
{
! if( !$query_id )
! {
$query_id = $this->query_result;
}
+
$result['message'] = @pg_errormessage($this->db_connect_id);
$result['code'] = -1;
+
return $result;
}
|