mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-15 05:04:09 +02:00
oh boy...
- Migrate code base to PHP 5.1+ git-svn-id: file:///svn/phpbb/trunk@8295 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
@@ -253,7 +253,7 @@ class phpbb_db_tools
|
||||
|
||||
/**
|
||||
*/
|
||||
function phpbb_db_tools(&$db)
|
||||
function __construct(&$db)
|
||||
{
|
||||
$this->db = $db;
|
||||
|
||||
|
@@ -66,7 +66,7 @@ class dbal
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function dbal()
|
||||
function __construct()
|
||||
{
|
||||
$this->num_queries = array(
|
||||
'cached' => 0,
|
||||
|
@@ -27,7 +27,6 @@ class dbal_firebird extends dbal
|
||||
{
|
||||
var $last_query_text = '';
|
||||
var $service_handle = false;
|
||||
var $affected_rows = 0;
|
||||
|
||||
/**
|
||||
* Connect to server
|
||||
@@ -41,7 +40,7 @@ class dbal_firebird extends dbal
|
||||
|
||||
$this->db_connect_id = ($this->persistency) ? @ibase_pconnect($this->server . ':' . $this->dbname, $this->user, $sqlpassword, false, false, 3) : @ibase_connect($this->server . ':' . $this->dbname, $this->user, $sqlpassword, false, false, 3);
|
||||
|
||||
$this->service_handle = (function_exists('ibase_service_attach')) ? @ibase_service_attach($this->server, $this->user, $sqlpassword) : false;
|
||||
$this->service_handle = (strtolower($this->user) == 'sysdba') ? @ibase_service_attach($this->server, $this->user, $sqlpassword) : false;
|
||||
|
||||
return ($this->db_connect_id) ? $this->db_connect_id : $this->sql_error('');
|
||||
}
|
||||
@@ -51,7 +50,7 @@ class dbal_firebird extends dbal
|
||||
*/
|
||||
function sql_server_info()
|
||||
{
|
||||
if ($this->service_handle !== false && function_exists('ibase_server_info'))
|
||||
if ($this->service_handle !== false)
|
||||
{
|
||||
return @ibase_server_info($this->service_handle, IBASE_SVC_SERVER_VERSION);
|
||||
}
|
||||
@@ -164,25 +163,6 @@ class dbal_firebird extends dbal
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('ibase_affected_rows') && (preg_match('/^UPDATE ([\w_]++)\s+SET [\w_]++\s*=\s*(?:\'(?:[^\']++|\'\')*+\'|[\d-.]+)(?:,\s*[\w_]++\s*=\s*(?:\'(?:[^\']++|\'\')*+\'|[\d-.]+))*+\s+(WHERE.*)?$/s', $query, $regs) || preg_match('/^DELETE FROM ([\w_]++)\s*(WHERE\s*.*)?$/s', $query, $regs)))
|
||||
{
|
||||
$affected_sql = 'SELECT COUNT(*) as num_rows_affected FROM ' . $regs[1];
|
||||
if (!empty($regs[2]))
|
||||
{
|
||||
$affected_sql .= ' ' . $regs[2];
|
||||
}
|
||||
|
||||
if (!($temp_q_id = @ibase_query($this->db_connect_id, $affected_sql)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$temp_result = @ibase_fetch_assoc($temp_q_id);
|
||||
@ibase_free_result($temp_q_id);
|
||||
|
||||
$this->affected_rows = ($temp_result) ? $temp_result['NUM_ROWS_AFFECTED'] : false;
|
||||
}
|
||||
|
||||
if (sizeof($array))
|
||||
{
|
||||
$p_query = @ibase_prepare($this->db_connect_id, $query);
|
||||
@@ -207,15 +187,7 @@ class dbal_firebird extends dbal
|
||||
|
||||
if (!$this->transaction)
|
||||
{
|
||||
if (function_exists('ibase_commit_ret'))
|
||||
{
|
||||
@ibase_commit_ret();
|
||||
}
|
||||
else
|
||||
{
|
||||
// way cooler than ibase_commit_ret :D
|
||||
@ibase_query('COMMIT RETAIN;');
|
||||
}
|
||||
@ibase_commit_ret();
|
||||
}
|
||||
|
||||
if ($cache_ttl && method_exists($cache, 'sql_save'))
|
||||
@@ -258,15 +230,7 @@ class dbal_firebird extends dbal
|
||||
*/
|
||||
function sql_affectedrows()
|
||||
{
|
||||
// PHP 5+ function
|
||||
if (function_exists('ibase_affected_rows'))
|
||||
{
|
||||
return ($this->db_connect_id) ? @ibase_affected_rows($this->db_connect_id) : false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->affected_rows;
|
||||
}
|
||||
return ($this->db_connect_id) ? @ibase_affected_rows($this->db_connect_id) : false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -438,7 +402,7 @@ class dbal_firebird extends dbal
|
||||
{
|
||||
return array(
|
||||
'message' => @ibase_errmsg(),
|
||||
'code' => (@function_exists('ibase_errcode') ? @ibase_errcode() : '')
|
||||
'code' => @ibase_errcode()
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -39,14 +39,7 @@ class dbal_mssql extends dbal
|
||||
@ini_set('mssql.textlimit', 2147483647);
|
||||
@ini_set('mssql.textsize', 2147483647);
|
||||
|
||||
if (version_compare(PHP_VERSION, '5.1.0', '>=') || (version_compare(PHP_VERSION, '5.0.0-dev', '<=') && version_compare(PHP_VERSION, '4.4.1', '>=')))
|
||||
{
|
||||
$this->db_connect_id = ($this->persistency) ? @mssql_pconnect($this->server, $this->user, $sqlpassword, $new_link) : @mssql_connect($this->server, $this->user, $sqlpassword, $new_link);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db_connect_id = ($this->persistency) ? @mssql_pconnect($this->server, $this->user, $sqlpassword) : @mssql_connect($this->server, $this->user, $sqlpassword);
|
||||
}
|
||||
$this->db_connect_id = ($this->persistency) ? @mssql_pconnect($this->server, $this->user, $sqlpassword, $new_link) : @mssql_connect($this->server, $this->user, $sqlpassword, $new_link);
|
||||
|
||||
if ($this->db_connect_id && $this->dbname != '')
|
||||
{
|
||||
|
@@ -362,11 +362,12 @@ class dbal_mysql extends dbal
|
||||
function _sql_report($mode, $query = '')
|
||||
{
|
||||
static $test_prof;
|
||||
static $test_extend;
|
||||
|
||||
// current detection method, might just switch to see the existance of INFORMATION_SCHEMA.PROFILING
|
||||
if ($test_prof === null)
|
||||
{
|
||||
$test_prof = false;
|
||||
$test_prof = $test_extend = false;
|
||||
if (strpos($this->mysql_version, 'community') !== false)
|
||||
{
|
||||
$ver = substr($this->mysql_version, 0, strpos($this->mysql_version, '-'));
|
||||
@@ -375,6 +376,11 @@ class dbal_mysql extends dbal
|
||||
$test_prof = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (version_compare($ver, '4.1.1', '>='))
|
||||
{
|
||||
$test_extend = true;
|
||||
}
|
||||
}
|
||||
|
||||
switch ($mode)
|
||||
@@ -401,7 +407,7 @@ class dbal_mysql extends dbal
|
||||
@mysql_query('SET profiling = 1;', $this->db_connect_id);
|
||||
}
|
||||
|
||||
if ($result = @mysql_query("EXPLAIN $explain_query", $this->db_connect_id))
|
||||
if ($result = @mysql_query('EXPLAIN ' . (($test_extend) ? 'EXTENDED ' : '') . "$explain_query", $this->db_connect_id))
|
||||
{
|
||||
while ($row = @mysql_fetch_assoc($result))
|
||||
{
|
||||
@@ -415,6 +421,27 @@ class dbal_mysql extends dbal
|
||||
$this->html_hold .= '</table>';
|
||||
}
|
||||
|
||||
if ($test_extend)
|
||||
{
|
||||
$html_table = false;
|
||||
|
||||
if ($result = @mysql_query('SHOW WARNINGS', $this->db_connect_id))
|
||||
{
|
||||
$this->html_hold .= '<br />';
|
||||
while ($row = @mysql_fetch_assoc($result))
|
||||
{
|
||||
$html_table = $this->sql_report('add_select_row', $query, $html_table, $row);
|
||||
}
|
||||
}
|
||||
@mysql_free_result($result);
|
||||
|
||||
if ($html_table)
|
||||
{
|
||||
$this->html_hold .= '</table>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($test_prof)
|
||||
{
|
||||
$html_table = false;
|
||||
|
@@ -48,7 +48,7 @@ class dbal_oracle extends dbal
|
||||
$connect = $sqlserver . (($port) ? ':' . $port : '') . '/' . $database;
|
||||
}
|
||||
|
||||
$this->db_connect_id = ($new_link) ? @ocinlogon($this->user, $sqlpassword, $connect, 'UTF8') : (($this->persistency) ? @ociplogon($this->user, $sqlpassword, $connect, 'UTF8') : @ocilogon($this->user, $sqlpassword, $connect, 'UTF8'));
|
||||
$this->db_connect_id = ($new_link) ? @oci_new_connect($this->user, $sqlpassword, $connect, 'UTF8') : (($this->persistency) ? @oci_pconnect($this->user, $sqlpassword, $connect, 'UTF8') : @oci_connect($this->user, $sqlpassword, $connect, 'UTF8'));
|
||||
|
||||
return ($this->db_connect_id) ? $this->db_connect_id : $this->sql_error('');
|
||||
}
|
||||
@@ -58,7 +58,7 @@ class dbal_oracle extends dbal
|
||||
*/
|
||||
function sql_server_info()
|
||||
{
|
||||
return @ociserverversion($this->db_connect_id);
|
||||
return @oci_server_version($this->db_connect_id);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,11 +74,11 @@ class dbal_oracle extends dbal
|
||||
break;
|
||||
|
||||
case 'commit':
|
||||
return @ocicommit($this->db_connect_id);
|
||||
return @oci_commit($this->db_connect_id);
|
||||
break;
|
||||
|
||||
case 'rollback':
|
||||
return @ocirollback($this->db_connect_id);
|
||||
return @oci_rollback($this->db_connect_id);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -308,14 +308,14 @@ class dbal_oracle extends dbal
|
||||
break;
|
||||
}
|
||||
|
||||
$this->query_result = @ociparse($this->db_connect_id, $query);
|
||||
$this->query_result = @oci_parse($this->db_connect_id, $query);
|
||||
|
||||
foreach ($array as $key => $value)
|
||||
{
|
||||
@ocibindbyname($this->query_result, $key, $array[$key], -1);
|
||||
@oci_bind_by_name($this->query_result, $key, $array[$key], -1);
|
||||
}
|
||||
|
||||
$success = @ociexecute($this->query_result, OCI_DEFAULT);
|
||||
$success = @oci_execute($this->query_result, OCI_DEFAULT);
|
||||
|
||||
if (!$success)
|
||||
{
|
||||
@@ -375,7 +375,7 @@ class dbal_oracle extends dbal
|
||||
*/
|
||||
function sql_affectedrows()
|
||||
{
|
||||
return ($this->query_result) ? @ocirowcount($this->query_result) : false;
|
||||
return ($this->query_result) ? @oci_num_rows($this->query_result) : false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -398,9 +398,9 @@ class dbal_oracle extends dbal
|
||||
if ($query_id !== false)
|
||||
{
|
||||
$row = array();
|
||||
$result = @ocifetchinto($query_id, $row, OCI_ASSOC + OCI_RETURN_NULLS);
|
||||
$row = @oci_fetch_array($query_id, OCI_ASSOC + OCI_RETURN_NULLS);
|
||||
|
||||
if (!$result || !$row)
|
||||
if (!$row)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -453,7 +453,7 @@ class dbal_oracle extends dbal
|
||||
}
|
||||
|
||||
// Reset internal pointer
|
||||
@ociexecute($query_id, OCI_DEFAULT);
|
||||
@oci_execute($query_id, OCI_DEFAULT);
|
||||
|
||||
// We do not fetch the row for rownum == 0 because then the next resultset would be the second row
|
||||
for ($i = 0; $i < $rownum; $i++)
|
||||
@@ -479,13 +479,13 @@ class dbal_oracle extends dbal
|
||||
if (preg_match('#^INSERT[\t\n ]+INTO[\t\n ]+([a-z0-9\_\-]+)#is', $this->last_query_text, $tablename))
|
||||
{
|
||||
$query = 'SELECT ' . $tablename[1] . '_seq.currval FROM DUAL';
|
||||
$stmt = @ociparse($this->db_connect_id, $query);
|
||||
@ociexecute($stmt, OCI_DEFAULT);
|
||||
$stmt = @oci_parse($this->db_connect_id, $query);
|
||||
@oci_execute($stmt, OCI_DEFAULT);
|
||||
|
||||
$temp_result = @ocifetchinto($stmt, $temp_array, OCI_ASSOC + OCI_RETURN_NULLS);
|
||||
@ocifreestatement($stmt);
|
||||
$temp_array = @oci_fetch_array($stmt, OCI_ASSOC + OCI_RETURN_NULLS);
|
||||
@oci_free_statement($stmt);
|
||||
|
||||
if ($temp_result)
|
||||
if ($temp_array)
|
||||
{
|
||||
return $temp_array['CURRVAL'];
|
||||
}
|
||||
@@ -519,7 +519,7 @@ class dbal_oracle extends dbal
|
||||
if (isset($this->open_queries[(int) $query_id]))
|
||||
{
|
||||
unset($this->open_queries[(int) $query_id]);
|
||||
return @ocifreestatement($query_id);
|
||||
return @oci_free_statement($query_id);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -553,9 +553,9 @@ class dbal_oracle extends dbal
|
||||
*/
|
||||
function _sql_error()
|
||||
{
|
||||
$error = @ocierror();
|
||||
$error = (!$error) ? @ocierror($this->query_result) : $error;
|
||||
$error = (!$error) ? @ocierror($this->db_connect_id) : $error;
|
||||
$error = @oci_error();
|
||||
$error = (!$error) ? @oci_error($this->query_result) : $error;
|
||||
$error = (!$error) ? @oci_error($this->db_connect_id) : $error;
|
||||
|
||||
if ($error)
|
||||
{
|
||||
@@ -575,7 +575,7 @@ class dbal_oracle extends dbal
|
||||
*/
|
||||
function _sql_close()
|
||||
{
|
||||
return @ocilogoff($this->db_connect_id);
|
||||
return @oci_close($this->db_connect_id);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -594,11 +594,11 @@ class dbal_oracle extends dbal
|
||||
$sql = "SELECT table_name
|
||||
FROM USER_TABLES
|
||||
WHERE table_name LIKE '%PLAN_TABLE%'";
|
||||
$stmt = ociparse($this->db_connect_id, $sql);
|
||||
ociexecute($stmt);
|
||||
$stmt = oci_parse($this->db_connect_id, $sql);
|
||||
oci_execute($stmt);
|
||||
$result = array();
|
||||
|
||||
if (ocifetchinto($stmt, $result, OCI_ASSOC + OCI_RETURN_NULLS))
|
||||
if ($result = oci_fetch_array($stmt, OCI_ASSOC + OCI_RETURN_NULLS))
|
||||
{
|
||||
$table = $result['TABLE_NAME'];
|
||||
|
||||
@@ -606,17 +606,17 @@ class dbal_oracle extends dbal
|
||||
$statement_id = substr(md5($query), 0, 30);
|
||||
|
||||
// Remove any stale plans
|
||||
$stmt2 = ociparse($this->db_connect_id, "DELETE FROM $table WHERE statement_id='$statement_id'");
|
||||
ociexecute($stmt2);
|
||||
ocifreestatement($stmt2);
|
||||
$stmt2 = oci_parse($this->db_connect_id, "DELETE FROM $table WHERE statement_id='$statement_id'");
|
||||
oci_execute($stmt2);
|
||||
oci_free_statement($stmt2);
|
||||
|
||||
// Explain the plan
|
||||
$sql = "EXPLAIN PLAN
|
||||
SET STATEMENT_ID = '$statement_id'
|
||||
FOR $query";
|
||||
$stmt2 = ociparse($this->db_connect_id, $sql);
|
||||
ociexecute($stmt2);
|
||||
ocifreestatement($stmt2);
|
||||
oci_execute($stmt2);
|
||||
oci_free_statement($stmt2);
|
||||
|
||||
// Get the data from the plan
|
||||
$sql = "SELECT operation, options, object_name, object_type, cardinality, cost
|
||||
@@ -624,24 +624,24 @@ class dbal_oracle extends dbal
|
||||
START WITH id = 0 AND statement_id = '$statement_id'
|
||||
CONNECT BY PRIOR id = parent_id
|
||||
AND statement_id = '$statement_id'";
|
||||
$stmt2 = ociparse($this->db_connect_id, $sql);
|
||||
ociexecute($stmt2);
|
||||
$stmt2 = oci_parse($this->db_connect_id, $sql);
|
||||
oci_execute($stmt2);
|
||||
|
||||
$row = array();
|
||||
while (ocifetchinto($stmt2, $row, OCI_ASSOC + OCI_RETURN_NULLS))
|
||||
while ($row = oci_fetch_array($stmt2, OCI_ASSOC + OCI_RETURN_NULLS))
|
||||
{
|
||||
$html_table = $this->sql_report('add_select_row', $query, $html_table, $row);
|
||||
}
|
||||
|
||||
ocifreestatement($stmt2);
|
||||
oci_free_statement($stmt2);
|
||||
|
||||
// Remove the plan we just made, we delete them on request anyway
|
||||
$stmt2 = ociparse($this->db_connect_id, "DELETE FROM $table WHERE statement_id='$statement_id'");
|
||||
ociexecute($stmt2);
|
||||
ocifreestatement($stmt2);
|
||||
$stmt2 = oci_parse($this->db_connect_id, "DELETE FROM $table WHERE statement_id='$statement_id'");
|
||||
oci_execute($stmt2);
|
||||
oci_free_statement($stmt2);
|
||||
}
|
||||
|
||||
ocifreestatement($stmt);
|
||||
oci_free_statement($stmt);
|
||||
|
||||
if ($html_table)
|
||||
{
|
||||
@@ -654,15 +654,15 @@ class dbal_oracle extends dbal
|
||||
$endtime = explode(' ', microtime());
|
||||
$endtime = $endtime[0] + $endtime[1];
|
||||
|
||||
$result = @ociparse($this->db_connect_id, $query);
|
||||
$success = @ociexecute($result, OCI_DEFAULT);
|
||||
$result = @oci_parse($this->db_connect_id, $query);
|
||||
$success = @oci_execute($result, OCI_DEFAULT);
|
||||
$row = array();
|
||||
|
||||
while (@ocifetchinto($result, $row, OCI_ASSOC + OCI_RETURN_NULLS))
|
||||
while ($void = @oci_fetch_array($result, OCI_ASSOC + OCI_RETURN_NULLS))
|
||||
{
|
||||
// Take the time spent on parsing rows into account
|
||||
}
|
||||
@ocifreestatement($result);
|
||||
@oci_free_statement($result);
|
||||
|
||||
$splittime = explode(' ', microtime());
|
||||
$splittime = $splittime[0] + $splittime[1];
|
||||
|
@@ -82,21 +82,7 @@ class dbal_postgres extends dbal
|
||||
if ($this->db_connect_id)
|
||||
{
|
||||
// determine what version of PostgreSQL is running, we can be more efficient if they are running 8.2+
|
||||
if (version_compare(PHP_VERSION, '5.0.0', '>='))
|
||||
{
|
||||
$this->pgsql_version = @pg_parameter_status($this->db_connect_id, 'server_version');
|
||||
}
|
||||
else
|
||||
{
|
||||
$query_id = @pg_query($this->db_connect_id, 'SELECT VERSION()');
|
||||
$row = @pg_fetch_assoc($query_id, null);
|
||||
@pg_free_result($query_id);
|
||||
|
||||
if (!empty($row['version']))
|
||||
{
|
||||
$this->pgsql_version = substr($row['version'], 10);
|
||||
}
|
||||
}
|
||||
$this->pgsql_version = @pg_parameter_status($this->db_connect_id, 'server_version');
|
||||
|
||||
if (!empty($this->pgsql_version) && $this->pgsql_version[0] >= '8' && $this->pgsql_version[2] >= '2')
|
||||
{
|
||||
@@ -172,7 +158,7 @@ class dbal_postgres extends dbal
|
||||
|
||||
if ($this->query_result === false)
|
||||
{
|
||||
if (($this->query_result = @pg_query($this->db_connect_id, $query)) === false)
|
||||
if (($this->query_result = pg_query($this->db_connect_id, $query)) === false)
|
||||
{
|
||||
$this->sql_error($query);
|
||||
}
|
||||
|
Reference in New Issue
Block a user