various fixes and alterations

git-svn-id: file:///svn/phpbb/trunk@4118 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Paul S. Owen 2003-06-12 17:11:43 +00:00
parent 68f6998a4c
commit dee0f40fd2
7 changed files with 298 additions and 207 deletions

View file

@ -33,8 +33,7 @@ class sql_db
var $sql_report = ''; var $sql_report = '';
var $sql_time = 0; var $sql_time = 0;
// Constructor function sql_connect($sqlserver, $sqluser, $sqlpassword, $database = '', $port = '', $persistency = false)
function sql_db($sqlserver, $sqluser, $sqlpassword, $database = '', $port = '', $persistency = false)
{ {
$this->open_queries = array(); $this->open_queries = array();
$this->num_queries = 0; $this->num_queries = 0;
@ -44,7 +43,7 @@ class sql_db
$this->password = $sqlpassword; $this->password = $sqlpassword;
$this->server = $sqlserver; $this->server = $sqlserver;
$this->db_connect_id =($this->persistency) ? ibase_pconnect($this->server, $this->user, $this->password) : ibase_connect($this->server, $this->user, $this->password); $this->db_connect_id =($this->persistency) ? @ibase_pconnect($this->server, $this->user, $this->password) : @ibase_connect($this->server, $this->user, $this->password);
return ($this->db_connect_id) ? $this->db_connect_id : $this->sql_error(''); return ($this->db_connect_id) ? $this->db_connect_id : $this->sql_error('');
} }

View file

@ -41,10 +41,7 @@ class sql_db
var $num_queries = 0; var $num_queries = 0;
// function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $persistency = true)
// Constructor
//
function sql_db($sqlserver, $sqluser, $sqlpassword, $database, $persistency = true)
{ {
$this->persistency = $persistency; $this->persistency = $persistency;
$this->server = $sqlserver; $this->server = $sqlserver;
@ -52,10 +49,21 @@ class sql_db
$this->password = $sqlpassword; $this->password = $sqlpassword;
$this->dbname = $database; $this->dbname = $database;
$this->db_connect_id = ($this->persistency) ? odbc_pconnect($this->server, $this->user, $this->password) : odbc_connect($this->server, $this->user, $this->password); $this->db_connect_id = ($this->persistency) ? @odbc_pconnect($this->server, $this->user, $this->password) : @odbc_connect($this->server, $this->user, $this->password);
return ( $this->db_connect_id ) ? $this->db_connect_id : false; return ($this->db_connect_id) ? $this->db_connect_id : $this->sql_error('');
} }
function sql_return_on_error($fail = false)
{
$this->return_on_error = $fail;
}
function sql_num_queries()
{
return $this->num_queries;
}
// //
// Other base methods // Other base methods
// //
@ -374,12 +382,28 @@ class sql_db
return true; return true;
} }
function sql_error() function sql_error($sql = '')
{ {
$error['code'] = "";//odbc_error($this->db_connect_id); if (!$this->return_on_error)
$error['message'] = "Error";//odbc_errormsg($this->db_connect_id); {
if ($this->transaction)
{
$this->sql_transaction('rollback');
}
return $error; $this_page = (!empty($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : $_ENV['PHP_SELF'];
$this_page .= '&' . ((!empty($_SERVER['QUERY_STRING'])) ? $_SERVER['QUERY_STRING'] : $_ENV['QUERY_STRING']);
$message = '<u>SQL ERROR</u> [ ' . SQL_LAYER . ' ]<br /><br />' . @odbc_errormsg() . '<br /><br /><u>CALLING PAGE</u><br /><br />' . htmlspecialchars($this_page) . (($sql != '') ? '<br /><br /><u>SQL</u><br /><br />' . $sql : '') . '<br />';
trigger_error($message, E_USER_ERROR);
}
$result = array(
'message' => @odbc_errormsg(),
'code' => @odbc_error()
);
return $result;
} }
} // class sql_db } // class sql_db

View file

@ -40,10 +40,7 @@ class sql_db
var $num_queries = 0; var $num_queries = 0;
// function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $persistency = true)
// Constructor
//
function sql_db($sqlserver, $sqluser, $sqlpassword, $database, $persistency = true)
{ {
$this->persistency = $persistency; $this->persistency = $persistency;
$this->server = $sqlserver; $this->server = $sqlserver;
@ -51,10 +48,21 @@ class sql_db
$this->password = $sqlpassword; $this->password = $sqlpassword;
$this->dbname = $database; $this->dbname = $database;
$this->db_connect_id = ($this->persistency) ? odbc_pconnect($this->server, $this->user, $this->password) : odbc_connect($this->server, $this->user, $this->password); $this->db_connect_id = ($this->persistency) ? @odbc_pconnect($this->server, $this->user, $this->password) : @odbc_connect($this->server, $this->user, $this->password);
return ( $this->db_connect_id ) ? $this->db_connect_id : false; return ($this->db_connect_id) ? $this->db_connect_id : $this->sql_error('');
} }
function sql_return_on_error($fail = false)
{
$this->return_on_error = $fail;
}
function sql_num_queries()
{
return $this->num_queries;
}
// //
// Other base methods // Other base methods
// //
@ -372,12 +380,28 @@ class sql_db
return true; return true;
} }
function sql_error() function sql_error($sql = '')
{ {
$error['code'] = odbc_error($this->db_connect_id); if (!$this->return_on_error)
$error['message'] = odbc_errormsg($this->db_connect_id); {
if ($this->transaction)
{
$this->sql_transaction('rollback');
}
return $error; $this_page = (!empty($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : $_ENV['PHP_SELF'];
$this_page .= '&' . ((!empty($_SERVER['QUERY_STRING'])) ? $_SERVER['QUERY_STRING'] : $_ENV['QUERY_STRING']);
$message = '<u>SQL ERROR</u> [ ' . SQL_LAYER . ' ]<br /><br />' . @odbc_errormsg() . '<br /><br /><u>CALLING PAGE</u><br /><br />' . htmlspecialchars($this_page) . (($sql != '') ? '<br /><br /><u>SQL</u><br /><br />' . $sql : '') . '<br />';
trigger_error($message, E_USER_ERROR);
}
$result = array(
'message' => @odbc_errormsg(),
'code' => @odbc_error()
);
return $result;
} }
} // class sql_db } // class sql_db

View file

@ -40,10 +40,7 @@ class sql_db
var $num_queries = 0; var $num_queries = 0;
// function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $persistency = true)
// Constructor
//
function sql_db($sqlserver, $sqluser, $sqlpassword, $database, $persistency = true)
{ {
$this->persistency = $persistency; $this->persistency = $persistency;
$this->user = $sqluser; $this->user = $sqluser;
@ -51,18 +48,28 @@ class sql_db
$this->server = $sqlserver; $this->server = $sqlserver;
$this->dbname = $database; $this->dbname = $database;
$this->db_connect_id = ( $this->persistency ) ? mssql_pconnect($this->server, $this->user, $this->password) : mssql_connect($this->server, $this->user, $this->password); $this->db_connect_id = ($this->persistency) ? @mssql_pconnect($this->server, $this->user, $this->password) : @mssql_connect($this->server, $this->user, $this->password);
if( $this->db_connect_id && $this->dbname != "" ) if($this->db_connect_id && $this->dbname != '')
{ {
if( !mssql_select_db($this->dbname, $this->db_connect_id) ) if(!@mssql_select_db($this->dbname, $this->db_connect_id))
{ {
mssql_close($this->db_connect_id); @mssql_close($this->db_connect_id);
return false; return false;
} }
} }
return $this->db_connect_id; return ($this->db_connect_id) ? $this->db_connect_id : $this->sql_error('');
}
function sql_return_on_error($fail = false)
{
$this->return_on_error = $fail;
}
function sql_num_queries()
{
return $this->num_queries;
} }
// //
@ -408,9 +415,27 @@ class sql_db
return str_replace("'", "''", str_replace('\\', '\\\\', $msg)); return str_replace("'", "''", str_replace('\\', '\\\\', $msg));
} }
function sql_error($query_id = 0) function sql_error($sql = '')
{ {
$result['message'] = @mssql_get_last_message(); if (!$this->return_on_error)
{
if ($this->transaction)
{
$this->sql_transaction('rollback');
}
$this_page = (!empty($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : $_ENV['PHP_SELF'];
$this_page .= '&' . ((!empty($_SERVER['QUERY_STRING'])) ? $_SERVER['QUERY_STRING'] : $_ENV['QUERY_STRING']);
$message = '<u>SQL ERROR</u> [ ' . SQL_LAYER . ' ]<br /><br />' . @mssql_get_last_message() . '<br /><br /><u>CALLING PAGE</u><br /><br />' . htmlspecialchars($this_page) . (($sql != '') ? '<br /><br /><u>SQL</u><br /><br />' . $sql : '') . '<br />';
trigger_error($message, E_USER_ERROR);
}
$result = array(
'message' => @mssql_get_last_message(),
'code' => ''
);
return $result; return $result;
} }

View file

@ -35,10 +35,7 @@ class sql_db
var $num_queries = 0; var $num_queries = 0;
var $open_queries = array(); var $open_queries = array();
// function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false)
// Constructor
//
function sql_db($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false)
{ {
$this->persistency = $persistency; $this->persistency = $persistency;
$this->user = $sqluser; $this->user = $sqluser;
@ -56,7 +53,7 @@ class sql_db
} }
} }
$this->sql_error(''); return $this->sql_error('');
} }
// //
@ -415,11 +412,6 @@ class sql_db
function sql_error($sql = '') function sql_error($sql = '')
{ {
$result = array(
'message' => @mysql_error(),
'code' => @mysql_errno()
);
if (!$this->return_on_error) if (!$this->return_on_error)
{ {
if ($this->transaction) if ($this->transaction)
@ -434,6 +426,10 @@ class sql_db
trigger_error($message, E_USER_ERROR); trigger_error($message, E_USER_ERROR);
} }
$result = array(
'message' => @mysql_error(),
'code' => @mysql_errno()
);
return $result; return $result;
} }

View file

@ -35,8 +35,7 @@ class sql_db
var $num_queries = 0; var $num_queries = 0;
var $open_queries = array(); var $open_queries = array();
// Constructor function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port, $persistency = false)
function sql_db($sqlserver, $sqluser, $sqlpassword, $database, $port, $persistency = false)
{ {
$this->persistency = $persistency; $this->persistency = $persistency;
$this->user = $sqluser; $this->user = $sqluser;
@ -54,7 +53,7 @@ class sql_db
} }
} }
$this->sql_error(''); return $this->sql_error('');
} }
// Other base methods // Other base methods
@ -424,8 +423,10 @@ class sql_db
trigger_error($message, E_USER_ERROR); trigger_error($message, E_USER_ERROR);
} }
$result['message'] = @mysql_error(); $result = array(
$result['code'] = @mysql_errno(); 'message' => @mysql_error(),
'code' => @mysql_errno()
);
return $result; return $result;
} }

View file

@ -38,7 +38,7 @@ class sql_db
// //
// Constructor // Constructor
// //
function sql_db($sqlserver, $sqluser, $sqlpassword, $database, $persistency = true) function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $persistency = true)
{ {
$this->connect_string = ""; $this->connect_string = "";
@ -76,9 +76,19 @@ class sql_db
$this->persistency = $persistency; $this->persistency = $persistency;
$this->db_connect_id = ($this->persistency) ? pg_pconnect($this->connect_string) : pg_connect($this->connect_string); $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; return ($this->db_connect_id) ? $this->db_connect_id : $this->sql_error('');
}
function sql_return_on_error($fail = false)
{
$this->return_on_error = $fail;
}
function sql_num_queries()
{
return $this->num_queries;
} }
// //
@ -351,15 +361,27 @@ class sql_db
return ($query_id) ? @pg_freeresult($query_id) : false; return ($query_id) ? @pg_freeresult($query_id) : false;
} }
function sql_error($query_id = 0) function sql_error($sql = '')
{ {
if (!$query_id)
if (!$this->return_on_error)
{ {
$query_id = $this->query_result; if ($this->transaction)
{
$this->sql_transaction('rollback');
} }
$result['message'] = @pg_errormessage($this->db_connect_id); $this_page = (!empty($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : $_ENV['PHP_SELF'];
$result['code'] = -1; $this_page .= '&' . ((!empty($_SERVER['QUERY_STRING'])) ? $_SERVER['QUERY_STRING'] : $_ENV['QUERY_STRING']);
$message = '<u>SQL ERROR</u> [ ' . SQL_LAYER . ' ]<br /><br />' . @pg_errormessage() . '<br /><br /><u>CALLING PAGE</u><br /><br />' . htmlspecialchars($this_page) . (($sql != '') ? '<br /><br /><u>SQL</u><br /><br />' . $sql : '') . '<br />';
trigger_error($message, E_USER_ERROR);
}
$result = array(
'message' => @pg_errormessage(),
'code' => ''
);
return $result; return $result;
} }