|
From: Paul S. O. <ps...@us...> - 2002-07-14 14:39:04
|
Update of /cvsroot/phpbb/phpBB2/db
In directory usw-pr-cvs1:/tmp/cvs-serv13287/db
Modified Files:
mysql.php
Log Message:
Various updates which will break yet more things
Index: mysql.php
===================================================================
RCS file: /cvsroot/phpbb/phpBB2/db/mysql.php,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -r1.17 -r1.18
*** mysql.php 9 Jun 2002 00:04:44 -0000 1.17
--- mysql.php 14 Jul 2002 14:39:01 -0000 1.18
***************
*** 20,24 ****
***************************************************************************/
! if(!defined('SQL_LAYER'))
{
--- 20,24 ----
***************************************************************************/
! if ( !defined('SQL_LAYER') )
{
***************
*** 29,38 ****
var $db_connect_id;
var $query_result;
! var $return_on_error;
//
// Constructor
//
! function sql_db($sqlserver, $sqluser, $sqlpassword, $database, $persistency = false)
{
$this->open_queries = array();
--- 29,39 ----
var $db_connect_id;
var $query_result;
! var $return_on_error = false;
! var $transaction = false;
//
// Constructor
//
! function sql_db($sqlserver, $sqluser, $sqlpassword, $database, $port, $persistency = false)
{
$this->open_queries = array();
***************
*** 42,69 ****
$this->user = $sqluser;
$this->password = $sqlpassword;
! $this->server = $sqlserver;
! $this->port = 3306;
$this->dbname = $database;
$this->db_connect_id = ( $this->persistency ) ? @mysql_pconnect($this->server, $this->user, $this->password) : @mysql_connect($this->server, $this->user, $this->password);
! if ( $this->db_connect_id )
{
! if ( $database != '' )
{
! $this->dbname = $database;
! if ( !($dbselect = @mysql_select_db($this->dbname)) )
! {
! @mysql_close($this->db_connect_id);
! $this->db_connect_id = false;
! }
}
-
- return $this->db_connect_id;
- }
- else
- {
- return false;
}
}
--- 43,60 ----
$this->user = $sqluser;
$this->password = $sqlpassword;
! $this->server = $sqlserver . ( ( $port ) ? ':' . $port : '' );
$this->dbname = $database;
$this->db_connect_id = ( $this->persistency ) ? @mysql_pconnect($this->server, $this->user, $this->password) : @mysql_connect($this->server, $this->user, $this->password);
! if ( $this->db_connect_id && $this->dbname != '')
{
! if ( @mysql_select_db($this->dbname) )
{
! return $this->db_connect_id;
}
}
+
+ $this->sql_error('');
}
***************
*** 73,92 ****
function sql_close()
{
! if ( $this->db_connect_id )
{
! if ( count($this->open_queries) )
! {
! foreach($this->open_queries as $query_id)
! {
! @mysql_free_result($query_id);
! }
! }
!
! return @mysql_close($this->db_connect_id);
}
! else
{
! return false;
}
}
--- 64,81 ----
function sql_close()
{
! if ( !$this->db_connect_id )
{
! return false;
}
!
! if ( count($this->open_queries) )
{
! foreach($this->open_queries as $query_id)
! {
! @mysql_free_result($query_id);
! }
}
+
+ return @mysql_close($this->db_connect_id);
}
***************
*** 101,119 ****
}
! function sql_transaction($status = BEGIN_TRANSACTION)
{
- $result = true;
-
switch ( $status )
{
! case BEGIN_TRANSACTION:
// $result = mysql_query('BEGIN', $this->db_connect_id);
break;
! case END_TRANSACTION:
// $result = mysql_query('COMMIT', $this->db_connect_id);
break;
! case ROLLBACK:
! // mysql_query('ROLLBACK', $this->db_connect_id);
break;
}
--- 90,111 ----
}
! function sql_transaction($status = 'begin')
{
switch ( $status )
{
! case 'begin':
! $this->transaction = true;
// $result = mysql_query('BEGIN', $this->db_connect_id);
break;
! case 'commit':
! $this->transaction = false;
// $result = mysql_query('COMMIT', $this->db_connect_id);
break;
! case 'rollback':
! $this->transaction = false;
! // $result = mysql_query('ROLLBACK', $this->db_connect_id);
break;
+ default:
+ $result = true;
}
***************
*** 131,135 ****
$this->num_queries++;
! $this->query_result = @mysql_query($query, $this->db_connect_id);
$this->open_queries[] = $this->query_result;
--- 123,130 ----
$this->num_queries++;
! if ( !($this->query_result = @mysql_query($query, $this->db_connect_id)) )
! {
! $this->sql_error($query);
! }
$this->open_queries[] = $this->query_result;
***************
*** 150,159 ****
$this->num_queries++;
! if ( isset($total) )
{
! $query .= ' LIMIT ' . ( ( isset($offset) ) ? $offset . ', ' . $total : $total );
}
- $this->query_result = @mysql_query($query, $this->db_connect_id);
$this->open_queries[] = $this->query_result;
}
--- 145,158 ----
$this->num_queries++;
! if ( !empty($total) )
! {
! $query .= ' LIMIT ' . ( ( !empty($offset) ) ? $offset . ', ' . $total : $total );
! }
!
! if ( !($this->query_result = @mysql_query($query, $this->db_connect_id)) )
{
! $this->sql_error($query);
}
$this->open_queries[] = $this->query_result;
}
***************
*** 169,203 ****
function sql_query_array($query = '', $assoc_ary = false, $transaction = false)
{
! if ( is_array($assoc_ary) )
{
! if ( strpos(' ' . $query, 'INSERT') == 1 )
! {
! $fields = '';
! $values = '';
! foreach ( $assoc_ary as $key => $var )
! {
! $fields .= ( ( $fields != '' ) ? ', ' : '' ) . $key;
! $values .= ( ( $values != '' ) ? ', ' : '' ) . ( ( is_string($var) ) ? '\'' . str_replace('\'', '\'\'', $var) . '\'' : $var );
! }
! $query = $query . ' (' . $fields . ') VALUES (' . $values . ')';
! }
! else
{
! $values = '';
! foreach ( $assoc_ary as $key => $var )
! {
! $values .= ( ( $values != '' ) ? ', ' : '' ) . $key . ' = ' . ( ( is_string($var) ) ? '\'' . str_replace('\'', '\'\'', $var) . '\'' : $var );
! }
!
! $query = preg_replace('/^(.*? SET )(.*?)$/is', '\1' . $values . ' \2', $query);
}
! return $this->sql_query($query);
}
else
{
! return false;
}
}
--- 168,200 ----
function sql_query_array($query = '', $assoc_ary = false, $transaction = false)
{
! if ( !is_array($assoc_ary) )
{
! return false;
! }
! if ( strpos(' ' . $query, 'INSERT') == 1 )
! {
! $fields = '';
! $values = '';
! foreach ( $assoc_ary as $key => $var )
{
! $fields .= ( ( $fields != '' ) ? ', ' : '' ) . $key;
! $values .= ( ( $values != '' ) ? ', ' : '' ) . ( ( is_string($var) ) ? '\'' . str_replace('\'', '\'\'', $var) . '\'' : $var );
}
! $query = $query . ' (' . $fields . ') VALUES (' . $values . ')';
}
else
{
! $values = '';
! foreach ( $assoc_ary as $key => $var )
! {
! $values .= ( ( $values != '' ) ? ', ' : '' ) . $key . ' = ' . ( ( is_string($var) ) ? '\'' . str_replace('\'', '\'\'', $var) . '\'' : $var );
! }
!
! $query = preg_replace('/^(.*? SET )(.*?)$/is', '\1' . $values . ' \2', $query);
}
+
+ return $this->sql_query($query);
}
***************
*** 207,210 ****
--- 204,208 ----
// NOTE :: Want to remove _ALL_ reliance on sql_numrows from core code ...
// don't want this here by a middle Milestone
+ //
function sql_numrows($query_id = false)
{
***************
*** 312,316 ****
function sql_nextid()
{
! return ( $this->db_connect_id ) ? @mysql_insert_id($this->db_connect_id) : false;;
}
--- 310,314 ----
function sql_nextid()
{
! return ( $this->db_connect_id ) ? @mysql_insert_id($this->db_connect_id) : false;
}
***************
*** 325,332 ****
}
! function sql_error($query_id = false)
{
! $result['message'] = @mysql_error($this->db_connect_id);
! $result['code'] = @mysql_errno($this->db_connect_id);
return $result;
--- 323,346 ----
}
! function sql_error($sql = '')
{
! global $HTTP_SERVER_VARS, $HTTP_ENV_VARS;
!
! if ( !$this->return_on_error )
! {
! if ( $this->transaction )
! {
! $this->sql_transaction(ROLLBACK);
! }
!
! $this_page = ( !empty($HTTP_SERVER_VARS['PHP_SELF']) ) ? $HTTP_SERVER_VARS['PHP_SELF'] : $HTTP_ENV_VARS['PHP_SELF'];
! $this_page .= '&' . ( ( !empty($HTTP_SERVER_VARS['QUERY_STRING']) ) ? $HTTP_SERVER_VARS['QUERY_STRING'] : $HTTP_ENV_VARS['QUERY_STRING'] );
!
! $message = '<u>SQL ERROR</u> [ ' . SQL_LAYER . ' ]<br /><br />' . @mysql_error() . '<br /><br /><u>PAGE</u><br /><br />' . $this_page . ( ( $sql != '' ) ? '<br /><br /><u>SQL</u><br /><br />' . $sql : '' ) . '<br />';
! message_die(ERROR, $message);
! }
!
! $result['message'] = @mysql_error();
! $result['code'] = @mysql_errno();
return $result;
|