mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
[ticket/12387] Cleanup *_free_result call and remove @ on that call
PHPBB3-12387
This commit is contained in:
parent
afe9d3c3f3
commit
2276c1c0f2
10 changed files with 231 additions and 137 deletions
|
@ -175,7 +175,7 @@ abstract class driver implements driver_interface
|
|||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if ($query_id !== false)
|
||||
if ($query_id)
|
||||
{
|
||||
$result = array();
|
||||
while ($row = $this->sql_fetchrow($query_id))
|
||||
|
@ -206,7 +206,7 @@ abstract class driver implements driver_interface
|
|||
return $cache->sql_rowseek($rownum, $query_id);
|
||||
}
|
||||
|
||||
if ($query_id === false)
|
||||
if (!$query_id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -214,7 +214,7 @@ abstract class driver implements driver_interface
|
|||
$this->sql_freeresult($query_id);
|
||||
$query_id = $this->sql_query($this->last_query_text);
|
||||
|
||||
if ($query_id === false)
|
||||
if (!$query_id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -243,7 +243,7 @@ abstract class driver implements driver_interface
|
|||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if ($query_id !== false)
|
||||
if ($query_id)
|
||||
{
|
||||
if ($rownum !== false)
|
||||
{
|
||||
|
|
|
@ -71,8 +71,8 @@ class mssql extends \phpbb\db\driver\driver
|
|||
$row = false;
|
||||
if ($result_id)
|
||||
{
|
||||
$row = @mssql_fetch_assoc($result_id);
|
||||
@mssql_free_result($result_id);
|
||||
$row = mssql_fetch_assoc($result_id);
|
||||
mssql_free_result($result_id);
|
||||
}
|
||||
|
||||
$this->sql_server_version = ($row) ? trim(implode(' ', $row)) : 0;
|
||||
|
@ -153,6 +153,11 @@ class mssql extends \phpbb\db\driver\driver
|
|||
$this->sql_report('stop', $query);
|
||||
}
|
||||
|
||||
if (!$this->query_result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($cache && $cache_ttl)
|
||||
{
|
||||
$this->open_queries[(int) $this->query_result] = $this->query_result;
|
||||
|
@ -233,12 +238,12 @@ class mssql extends \phpbb\db\driver\driver
|
|||
return $cache->sql_fetchrow($query_id);
|
||||
}
|
||||
|
||||
if ($query_id === false)
|
||||
if (!$query_id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$row = @mssql_fetch_assoc($query_id);
|
||||
$row = mssql_fetch_assoc($query_id);
|
||||
|
||||
// I hope i am able to remove this later... hopefully only a PHP or MSSQL bug
|
||||
if ($row)
|
||||
|
@ -269,7 +274,7 @@ class mssql extends \phpbb\db\driver\driver
|
|||
return $cache->sql_rowseek($rownum, $query_id);
|
||||
}
|
||||
|
||||
return ($query_id !== false) ? @mssql_data_seek($query_id, $rownum) : false;
|
||||
return ($query_id) ? @mssql_data_seek($query_id, $rownum) : false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -280,12 +285,12 @@ class mssql extends \phpbb\db\driver\driver
|
|||
$result_id = @mssql_query('SELECT SCOPE_IDENTITY()', $this->db_connect_id);
|
||||
if ($result_id)
|
||||
{
|
||||
if ($row = @mssql_fetch_assoc($result_id))
|
||||
if ($row = mssql_fetch_assoc($result_id))
|
||||
{
|
||||
@mssql_free_result($result_id);
|
||||
mssql_free_result($result_id);
|
||||
return $row['computed'];
|
||||
}
|
||||
@mssql_free_result($result_id);
|
||||
mssql_free_result($result_id);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -311,7 +316,7 @@ class mssql extends \phpbb\db\driver\driver
|
|||
if (isset($this->open_queries[(int) $query_id]))
|
||||
{
|
||||
unset($this->open_queries[(int) $query_id]);
|
||||
return @mssql_free_result($query_id);
|
||||
return mssql_free_result($query_id);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -359,9 +364,9 @@ class mssql extends \phpbb\db\driver\driver
|
|||
$result_id = @mssql_query('SELECT @@ERROR as code', $this->db_connect_id);
|
||||
if ($result_id)
|
||||
{
|
||||
$row = @mssql_fetch_assoc($result_id);
|
||||
$row = mssql_fetch_assoc($result_id);
|
||||
$error['code'] = $row['code'];
|
||||
@mssql_free_result($result_id);
|
||||
mssql_free_result($result_id);
|
||||
}
|
||||
|
||||
// Get full error message if possible
|
||||
|
@ -372,12 +377,12 @@ class mssql extends \phpbb\db\driver\driver
|
|||
|
||||
if ($result_id)
|
||||
{
|
||||
$row = @mssql_fetch_assoc($result_id);
|
||||
$row = mssql_fetch_assoc($result_id);
|
||||
if (!empty($row['message']))
|
||||
{
|
||||
$error['message'] .= '<br />' . $row['message'];
|
||||
}
|
||||
@mssql_free_result($result_id);
|
||||
mssql_free_result($result_id);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -423,13 +428,13 @@ class mssql extends \phpbb\db\driver\driver
|
|||
if ($result = @mssql_query($query, $this->db_connect_id))
|
||||
{
|
||||
@mssql_next_result($result);
|
||||
while ($row = @mssql_fetch_row($result))
|
||||
while ($row = mssql_fetch_row($result))
|
||||
{
|
||||
$html_table = $this->sql_report('add_select_row', $query, $html_table, $row);
|
||||
}
|
||||
}
|
||||
@mssql_query('SET SHOWPLAN_TEXT OFF;', $this->db_connect_id);
|
||||
@mssql_free_result($result);
|
||||
mssql_free_result($result);
|
||||
|
||||
if ($html_table)
|
||||
{
|
||||
|
@ -442,11 +447,14 @@ class mssql extends \phpbb\db\driver\driver
|
|||
$endtime = $endtime[0] + $endtime[1];
|
||||
|
||||
$result = @mssql_query($query, $this->db_connect_id);
|
||||
while ($void = @mssql_fetch_assoc($result))
|
||||
if ($result)
|
||||
{
|
||||
while ($void = mssql_fetch_assoc($result))
|
||||
{
|
||||
// Take the time spent on parsing rows into account
|
||||
}
|
||||
@mssql_free_result($result);
|
||||
mssql_free_result($result);
|
||||
}
|
||||
|
||||
$splittime = explode(' ', microtime());
|
||||
$splittime = $splittime[0] + $splittime[1];
|
||||
|
|
|
@ -98,8 +98,8 @@ class mssql_odbc extends \phpbb\db\driver\mssql_base
|
|||
$row = false;
|
||||
if ($result_id)
|
||||
{
|
||||
$row = @odbc_fetch_array($result_id);
|
||||
@odbc_free_result($result_id);
|
||||
$row = odbc_fetch_array($result_id);
|
||||
odbc_free_result($result_id);
|
||||
}
|
||||
|
||||
$this->sql_server_version = ($row) ? trim(implode(' ', $row)) : 0;
|
||||
|
@ -173,6 +173,11 @@ class mssql_odbc extends \phpbb\db\driver\mssql_base
|
|||
$this->sql_report('stop', $query);
|
||||
}
|
||||
|
||||
if (!$this->query_result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($cache && $cache_ttl)
|
||||
{
|
||||
$this->open_queries[(int) $this->query_result] = $this->query_result;
|
||||
|
@ -253,7 +258,7 @@ class mssql_odbc extends \phpbb\db\driver\mssql_base
|
|||
return $cache->sql_fetchrow($query_id);
|
||||
}
|
||||
|
||||
return ($query_id !== false) ? @odbc_fetch_array($query_id) : false;
|
||||
return ($query_id) ? odbc_fetch_array($query_id) : false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -265,13 +270,13 @@ class mssql_odbc extends \phpbb\db\driver\mssql_base
|
|||
|
||||
if ($result_id)
|
||||
{
|
||||
if (@odbc_fetch_array($result_id))
|
||||
if (odbc_fetch_array($result_id))
|
||||
{
|
||||
$id = @odbc_result($result_id, 1);
|
||||
@odbc_free_result($result_id);
|
||||
$id = odbc_result($result_id, 1);
|
||||
odbc_free_result($result_id);
|
||||
return $id;
|
||||
}
|
||||
@odbc_free_result($result_id);
|
||||
odbc_free_result($result_id);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -297,7 +302,7 @@ class mssql_odbc extends \phpbb\db\driver\mssql_base
|
|||
if (isset($this->open_queries[(int) $query_id]))
|
||||
{
|
||||
unset($this->open_queries[(int) $query_id]);
|
||||
return @odbc_free_result($query_id);
|
||||
return odbc_free_result($query_id);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -352,11 +357,14 @@ class mssql_odbc extends \phpbb\db\driver\mssql_base
|
|||
$endtime = $endtime[0] + $endtime[1];
|
||||
|
||||
$result = @odbc_exec($this->db_connect_id, $query);
|
||||
while ($void = @odbc_fetch_array($result))
|
||||
if ($result)
|
||||
{
|
||||
while ($void = odbc_fetch_array($result))
|
||||
{
|
||||
// Take the time spent on parsing rows into account
|
||||
}
|
||||
@odbc_free_result($result);
|
||||
odbc_free_result($result);
|
||||
}
|
||||
|
||||
$splittime = explode(' ', microtime());
|
||||
$splittime = $splittime[0] + $splittime[1];
|
||||
|
|
|
@ -146,6 +146,11 @@ class mssqlnative extends \phpbb\db\driver\mssql_base
|
|||
$this->sql_report('stop', $query);
|
||||
}
|
||||
|
||||
if (!$this->query_result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($cache && $cache_ttl)
|
||||
{
|
||||
$this->open_queries[(int) $this->query_result] = $this->query_result;
|
||||
|
@ -234,12 +239,12 @@ class mssqlnative extends \phpbb\db\driver\mssql_base
|
|||
return $cache->sql_fetchrow($query_id);
|
||||
}
|
||||
|
||||
if ($query_id === false)
|
||||
if (!$query_id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$row = @sqlsrv_fetch_array($query_id, SQLSRV_FETCH_ASSOC);
|
||||
$row = sqlsrv_fetch_array($query_id, SQLSRV_FETCH_ASSOC);
|
||||
|
||||
if ($row)
|
||||
{
|
||||
|
@ -264,11 +269,11 @@ class mssqlnative extends \phpbb\db\driver\mssql_base
|
|||
{
|
||||
$result_id = @sqlsrv_query($this->db_connect_id, 'SELECT @@IDENTITY');
|
||||
|
||||
if ($result_id !== false)
|
||||
if ($result_id)
|
||||
{
|
||||
$row = @sqlsrv_fetch_array($result_id);
|
||||
$row = sqlsrv_fetch_array($result_id);
|
||||
$id = $row[0];
|
||||
@sqlsrv_free_stmt($result_id);
|
||||
sqlsrv_free_stmt($result_id);
|
||||
return $id;
|
||||
}
|
||||
else
|
||||
|
@ -297,7 +302,7 @@ class mssqlnative extends \phpbb\db\driver\mssql_base
|
|||
if (isset($this->open_queries[(int) $query_id]))
|
||||
{
|
||||
unset($this->open_queries[(int) $query_id]);
|
||||
return @sqlsrv_free_stmt($query_id);
|
||||
return sqlsrv_free_stmt($query_id);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -370,14 +375,14 @@ class mssqlnative extends \phpbb\db\driver\mssql_base
|
|||
@sqlsrv_query($this->db_connect_id, 'SET SHOWPLAN_TEXT ON;');
|
||||
if ($result = @sqlsrv_query($this->db_connect_id, $query))
|
||||
{
|
||||
@sqlsrv_next_result($result);
|
||||
while ($row = @sqlsrv_fetch_array($result))
|
||||
sqlsrv_next_result($result);
|
||||
while ($row = sqlsrv_fetch_array($result))
|
||||
{
|
||||
$html_table = $this->sql_report('add_select_row', $query, $html_table, $row);
|
||||
}
|
||||
sqlsrv_free_stmt($result);
|
||||
}
|
||||
@sqlsrv_query($this->db_connect_id, 'SET SHOWPLAN_TEXT OFF;');
|
||||
@sqlsrv_free_stmt($result);
|
||||
|
||||
if ($html_table)
|
||||
{
|
||||
|
@ -390,11 +395,14 @@ class mssqlnative extends \phpbb\db\driver\mssql_base
|
|||
$endtime = $endtime[0] + $endtime[1];
|
||||
|
||||
$result = @sqlsrv_query($this->db_connect_id, $query);
|
||||
while ($void = @sqlsrv_fetch_array($result))
|
||||
if ($result)
|
||||
{
|
||||
while ($void = sqlsrv_fetch_array($result))
|
||||
{
|
||||
// Take the time spent on parsing rows into account
|
||||
}
|
||||
@sqlsrv_free_stmt($result);
|
||||
sqlsrv_free_stmt($result);
|
||||
}
|
||||
|
||||
$splittime = explode(' ', microtime());
|
||||
$splittime = $splittime[0] + $splittime[1];
|
||||
|
|
|
@ -70,9 +70,16 @@ class mysql extends \phpbb\db\driver\mysql_base
|
|||
if (version_compare($this->sql_server_info(true), '5.0.2', '>='))
|
||||
{
|
||||
$result = @mysql_query('SELECT @@session.sql_mode AS sql_mode', $this->db_connect_id);
|
||||
$row = @mysql_fetch_assoc($result);
|
||||
@mysql_free_result($result);
|
||||
if ($result)
|
||||
{
|
||||
$row = mysql_fetch_assoc($result);
|
||||
mysql_free_result($result);
|
||||
$modes = array_map('trim', explode(',', $row['sql_mode']));
|
||||
}
|
||||
else
|
||||
{
|
||||
$modes = array();
|
||||
}
|
||||
|
||||
// TRADITIONAL includes STRICT_ALL_TABLES and STRICT_TRANS_TABLES
|
||||
if (!in_array('TRADITIONAL', $modes))
|
||||
|
@ -114,8 +121,10 @@ class mysql extends \phpbb\db\driver\mysql_base
|
|||
if (!$use_cache || empty($cache) || ($this->sql_server_version = $cache->get('mysql_version')) === false)
|
||||
{
|
||||
$result = @mysql_query('SELECT VERSION() AS version', $this->db_connect_id);
|
||||
$row = @mysql_fetch_assoc($result);
|
||||
@mysql_free_result($result);
|
||||
if ($result)
|
||||
{
|
||||
$row = mysql_fetch_assoc($result);
|
||||
mysql_free_result($result);
|
||||
|
||||
$this->sql_server_version = $row['version'];
|
||||
|
||||
|
@ -124,6 +133,7 @@ class mysql extends \phpbb\db\driver\mysql_base
|
|||
$cache->put('mysql_version', $this->sql_server_version);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ($raw) ? $this->sql_server_version : 'MySQL ' . $this->sql_server_version;
|
||||
}
|
||||
|
@ -182,6 +192,11 @@ class mysql extends \phpbb\db\driver\mysql_base
|
|||
$this->sql_report('stop', $query);
|
||||
}
|
||||
|
||||
if (!$this->query_result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($cache && $cache_ttl)
|
||||
{
|
||||
$this->open_queries[(int) $this->query_result] = $this->query_result;
|
||||
|
@ -249,7 +264,7 @@ class mysql extends \phpbb\db\driver\mysql_base
|
|||
return $cache->sql_fetchrow($query_id);
|
||||
}
|
||||
|
||||
return ($query_id !== false) ? @mysql_fetch_assoc($query_id) : false;
|
||||
return ($query_id) ? mysql_fetch_assoc($query_id) : false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -300,7 +315,7 @@ class mysql extends \phpbb\db\driver\mysql_base
|
|||
if (isset($this->open_queries[(int) $query_id]))
|
||||
{
|
||||
unset($this->open_queries[(int) $query_id]);
|
||||
return @mysql_free_result($query_id);
|
||||
return mysql_free_result($query_id);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -403,12 +418,12 @@ class mysql extends \phpbb\db\driver\mysql_base
|
|||
|
||||
if ($result = @mysql_query("EXPLAIN $explain_query", $this->db_connect_id))
|
||||
{
|
||||
while ($row = @mysql_fetch_assoc($result))
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
{
|
||||
$html_table = $this->sql_report('add_select_row', $query, $html_table, $row);
|
||||
}
|
||||
mysql_free_result($result);
|
||||
}
|
||||
@mysql_free_result($result);
|
||||
|
||||
if ($html_table)
|
||||
{
|
||||
|
@ -423,7 +438,7 @@ class mysql extends \phpbb\db\driver\mysql_base
|
|||
if ($result = @mysql_query('SHOW PROFILE ALL;', $this->db_connect_id))
|
||||
{
|
||||
$this->html_hold .= '<br />';
|
||||
while ($row = @mysql_fetch_assoc($result))
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
{
|
||||
// make <unknown> HTML safe
|
||||
if (!empty($row['Source_function']))
|
||||
|
@ -441,8 +456,8 @@ class mysql extends \phpbb\db\driver\mysql_base
|
|||
}
|
||||
$html_table = $this->sql_report('add_select_row', $query, $html_table, $row);
|
||||
}
|
||||
mysql_free_result($result);
|
||||
}
|
||||
@mysql_free_result($result);
|
||||
|
||||
if ($html_table)
|
||||
{
|
||||
|
@ -460,11 +475,14 @@ class mysql extends \phpbb\db\driver\mysql_base
|
|||
$endtime = $endtime[0] + $endtime[1];
|
||||
|
||||
$result = @mysql_query($query, $this->db_connect_id);
|
||||
while ($void = @mysql_fetch_assoc($result))
|
||||
if ($result)
|
||||
{
|
||||
while ($void = mysql_fetch_assoc($result))
|
||||
{
|
||||
// Take the time spent on parsing rows into account
|
||||
}
|
||||
@mysql_free_result($result);
|
||||
mysql_free_result($result);
|
||||
}
|
||||
|
||||
$splittime = explode(' ', microtime());
|
||||
$splittime = $splittime[0] + $splittime[1];
|
||||
|
|
|
@ -71,9 +71,10 @@ class mysqli extends \phpbb\db\driver\mysql_base
|
|||
if (version_compare($this->sql_server_info(true), '5.0.2', '>='))
|
||||
{
|
||||
$result = @mysqli_query($this->db_connect_id, 'SELECT @@session.sql_mode AS sql_mode');
|
||||
if ($result !== null)
|
||||
if ($result)
|
||||
{
|
||||
$row = @mysqli_fetch_assoc($result);
|
||||
$row = mysqli_fetch_assoc($result);
|
||||
mysqli_free_result($result);
|
||||
|
||||
$modes = array_map('trim', explode(',', $row['sql_mode']));
|
||||
}
|
||||
|
@ -81,7 +82,6 @@ class mysqli extends \phpbb\db\driver\mysql_base
|
|||
{
|
||||
$modes = array();
|
||||
}
|
||||
@mysqli_free_result($result);
|
||||
|
||||
// TRADITIONAL includes STRICT_ALL_TABLES and STRICT_TRANS_TABLES
|
||||
if (!in_array('TRADITIONAL', $modes))
|
||||
|
@ -116,9 +116,10 @@ class mysqli extends \phpbb\db\driver\mysql_base
|
|||
if (!$use_cache || empty($cache) || ($this->sql_server_version = $cache->get('mysqli_version')) === false)
|
||||
{
|
||||
$result = @mysqli_query($this->db_connect_id, 'SELECT VERSION() AS version');
|
||||
if ($result !== null)
|
||||
if ($result)
|
||||
{
|
||||
$row = @mysqli_fetch_assoc($result);
|
||||
$row = mysqli_fetch_assoc($result);
|
||||
mysqli_free_result($result);
|
||||
|
||||
$this->sql_server_version = $row['version'];
|
||||
|
||||
|
@ -127,7 +128,6 @@ class mysqli extends \phpbb\db\driver\mysql_base
|
|||
$cache->put('mysqli_version', $this->sql_server_version);
|
||||
}
|
||||
}
|
||||
@mysqli_free_result($result);
|
||||
}
|
||||
|
||||
return ($raw) ? $this->sql_server_version : 'MySQL(i) ' . $this->sql_server_version;
|
||||
|
@ -191,6 +191,11 @@ class mysqli extends \phpbb\db\driver\mysql_base
|
|||
$this->sql_report('stop', $query);
|
||||
}
|
||||
|
||||
if (!$this->query_result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($cache && $cache_ttl)
|
||||
{
|
||||
$this->query_result = $cache->sql_save($this, $query, $this->query_result, $cache_ttl);
|
||||
|
@ -234,9 +239,9 @@ class mysqli extends \phpbb\db\driver\mysql_base
|
|||
return $cache->sql_fetchrow($query_id);
|
||||
}
|
||||
|
||||
if ($query_id !== false && $query_id !== null)
|
||||
if ($query_id)
|
||||
{
|
||||
$result = @mysqli_fetch_assoc($query_id);
|
||||
$result = mysqli_fetch_assoc($query_id);
|
||||
return $result !== null ? $result : false;
|
||||
}
|
||||
|
||||
|
@ -260,7 +265,7 @@ class mysqli extends \phpbb\db\driver\mysql_base
|
|||
return $cache->sql_rowseek($rownum, $query_id);
|
||||
}
|
||||
|
||||
return ($query_id !== false) ? @mysqli_data_seek($query_id, $rownum) : false;
|
||||
return ($query_id) ? @mysqli_data_seek($query_id, $rownum) : false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -288,7 +293,12 @@ class mysqli extends \phpbb\db\driver\mysql_base
|
|||
return $cache->sql_freeresult($query_id);
|
||||
}
|
||||
|
||||
return @mysqli_free_result($query_id);
|
||||
if (!$this->query_result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return mysqli_free_result($query_id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -387,12 +397,12 @@ class mysqli extends \phpbb\db\driver\mysql_base
|
|||
|
||||
if ($result = @mysqli_query($this->db_connect_id, "EXPLAIN $explain_query"))
|
||||
{
|
||||
while ($row = @mysqli_fetch_assoc($result))
|
||||
while ($row = mysqli_fetch_assoc($result))
|
||||
{
|
||||
$html_table = $this->sql_report('add_select_row', $query, $html_table, $row);
|
||||
}
|
||||
mysqli_free_result($result);
|
||||
}
|
||||
@mysqli_free_result($result);
|
||||
|
||||
if ($html_table)
|
||||
{
|
||||
|
@ -407,7 +417,7 @@ class mysqli extends \phpbb\db\driver\mysql_base
|
|||
if ($result = @mysqli_query($this->db_connect_id, 'SHOW PROFILE ALL;'))
|
||||
{
|
||||
$this->html_hold .= '<br />';
|
||||
while ($row = @mysqli_fetch_assoc($result))
|
||||
while ($row = mysqli_fetch_assoc($result))
|
||||
{
|
||||
// make <unknown> HTML safe
|
||||
if (!empty($row['Source_function']))
|
||||
|
@ -425,8 +435,8 @@ class mysqli extends \phpbb\db\driver\mysql_base
|
|||
}
|
||||
$html_table = $this->sql_report('add_select_row', $query, $html_table, $row);
|
||||
}
|
||||
mysqli_free_result($result);
|
||||
}
|
||||
@mysqli_free_result($result);
|
||||
|
||||
if ($html_table)
|
||||
{
|
||||
|
@ -444,14 +454,14 @@ class mysqli extends \phpbb\db\driver\mysql_base
|
|||
$endtime = $endtime[0] + $endtime[1];
|
||||
|
||||
$result = @mysqli_query($this->db_connect_id, $query);
|
||||
if ($result !== null)
|
||||
if ($result)
|
||||
{
|
||||
while ($void = @mysqli_fetch_assoc($result))
|
||||
while ($void = mysqli_fetch_assoc($result))
|
||||
{
|
||||
// Take the time spent on parsing rows into account
|
||||
}
|
||||
mysqli_free_result($result);
|
||||
}
|
||||
@mysqli_free_result($result);
|
||||
|
||||
$splittime = explode(' ', microtime());
|
||||
$splittime = $splittime[0] + $splittime[1];
|
||||
|
|
|
@ -431,6 +431,11 @@ class oracle extends \phpbb\db\driver\driver
|
|||
$this->sql_report('stop', $query);
|
||||
}
|
||||
|
||||
if (!$this->query_result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($cache && $cache_ttl)
|
||||
{
|
||||
$this->open_queries[(int) $this->query_result] = $this->query_result;
|
||||
|
@ -491,10 +496,10 @@ class oracle extends \phpbb\db\driver\driver
|
|||
return $cache->sql_fetchrow($query_id);
|
||||
}
|
||||
|
||||
if ($query_id !== false)
|
||||
if ($query_id)
|
||||
{
|
||||
$row = array();
|
||||
$result = @ocifetchinto($query_id, $row, OCI_ASSOC + OCI_RETURN_NULLS);
|
||||
$result = ocifetchinto($query_id, $row, OCI_ASSOC + OCI_RETURN_NULLS);
|
||||
|
||||
if (!$result || !$row)
|
||||
{
|
||||
|
@ -542,7 +547,7 @@ class oracle extends \phpbb\db\driver\driver
|
|||
return $cache->sql_rowseek($rownum, $query_id);
|
||||
}
|
||||
|
||||
if ($query_id === false)
|
||||
if (!$query_id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -575,10 +580,14 @@ class oracle extends \phpbb\db\driver\driver
|
|||
{
|
||||
$query = 'SELECT ' . $tablename[1] . '_seq.currval FROM DUAL';
|
||||
$stmt = @ociparse($this->db_connect_id, $query);
|
||||
@ociexecute($stmt, OCI_DEFAULT);
|
||||
if ($stmt)
|
||||
{
|
||||
$success = @ociexecute($stmt, OCI_DEFAULT);
|
||||
|
||||
$temp_result = @ocifetchinto($stmt, $temp_array, OCI_ASSOC + OCI_RETURN_NULLS);
|
||||
@ocifreestatement($stmt);
|
||||
if ($success)
|
||||
{
|
||||
$temp_result = ocifetchinto($stmt, $temp_array, OCI_ASSOC + OCI_RETURN_NULLS);
|
||||
ocifreestatement($stmt);
|
||||
|
||||
if ($temp_result)
|
||||
{
|
||||
|
@ -590,6 +599,8 @@ class oracle extends \phpbb\db\driver\driver
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -614,7 +625,7 @@ class oracle extends \phpbb\db\driver\driver
|
|||
if (isset($this->open_queries[(int) $query_id]))
|
||||
{
|
||||
unset($this->open_queries[(int) $query_id]);
|
||||
return @ocifreestatement($query_id);
|
||||
return ocifreestatement($query_id);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -770,14 +781,20 @@ class oracle extends \phpbb\db\driver\driver
|
|||
$endtime = $endtime[0] + $endtime[1];
|
||||
|
||||
$result = @ociparse($this->db_connect_id, $query);
|
||||
if ($result)
|
||||
{
|
||||
$success = @ociexecute($result, OCI_DEFAULT);
|
||||
if ($success)
|
||||
{
|
||||
$row = array();
|
||||
|
||||
while (@ocifetchinto($result, $row, OCI_ASSOC + OCI_RETURN_NULLS))
|
||||
while (ocifetchinto($result, $row, OCI_ASSOC + OCI_RETURN_NULLS))
|
||||
{
|
||||
// Take the time spent on parsing rows into account
|
||||
}
|
||||
@ocifreestatement($result);
|
||||
}
|
||||
}
|
||||
|
||||
$splittime = explode(' ', microtime());
|
||||
$splittime = $splittime[0] + $splittime[1];
|
||||
|
|
|
@ -127,8 +127,10 @@ class postgres extends \phpbb\db\driver\driver
|
|||
if (!$use_cache || empty($cache) || ($this->sql_server_version = $cache->get('pgsql_version')) === false)
|
||||
{
|
||||
$query_id = @pg_query($this->db_connect_id, 'SELECT VERSION() AS version');
|
||||
$row = @pg_fetch_assoc($query_id, null);
|
||||
@pg_free_result($query_id);
|
||||
if ($query_id)
|
||||
{
|
||||
$row = pg_fetch_assoc($query_id, null);
|
||||
pg_free_result($query_id);
|
||||
|
||||
$this->sql_server_version = (!empty($row['version'])) ? trim(substr($row['version'], 10)) : 0;
|
||||
|
||||
|
@ -137,6 +139,7 @@ class postgres extends \phpbb\db\driver\driver
|
|||
$cache->put('pgsql_version', $this->sql_server_version);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ($raw) ? $this->sql_server_version : 'PostgreSQL ' . $this->sql_server_version;
|
||||
}
|
||||
|
@ -196,6 +199,11 @@ class postgres extends \phpbb\db\driver\driver
|
|||
$this->sql_report('stop', $query);
|
||||
}
|
||||
|
||||
if (!$this->query_result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($cache && $cache_ttl)
|
||||
{
|
||||
$this->open_queries[(int) $this->query_result] = $this->query_result;
|
||||
|
@ -271,7 +279,7 @@ class postgres extends \phpbb\db\driver\driver
|
|||
return $cache->sql_fetchrow($query_id);
|
||||
}
|
||||
|
||||
return ($query_id !== false) ? @pg_fetch_assoc($query_id, null) : false;
|
||||
return ($query_id) ? pg_fetch_assoc($query_id, null) : false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -291,7 +299,7 @@ class postgres extends \phpbb\db\driver\driver
|
|||
return $cache->sql_rowseek($rownum, $query_id);
|
||||
}
|
||||
|
||||
return ($query_id !== false) ? @pg_result_seek($query_id, $rownum) : false;
|
||||
return ($query_id) ? @pg_result_seek($query_id, $rownum) : false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -313,8 +321,8 @@ class postgres extends \phpbb\db\driver\driver
|
|||
return false;
|
||||
}
|
||||
|
||||
$temp_result = @pg_fetch_assoc($temp_q_id, null);
|
||||
@pg_free_result($query_id);
|
||||
$temp_result = pg_fetch_assoc($temp_q_id, null);
|
||||
pg_free_result($query_id);
|
||||
|
||||
return ($temp_result) ? $temp_result['last_value'] : false;
|
||||
}
|
||||
|
@ -343,7 +351,7 @@ class postgres extends \phpbb\db\driver\driver
|
|||
if (isset($this->open_queries[(int) $query_id]))
|
||||
{
|
||||
unset($this->open_queries[(int) $query_id]);
|
||||
return @pg_free_result($query_id);
|
||||
return pg_free_result($query_id);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -440,12 +448,12 @@ class postgres extends \phpbb\db\driver\driver
|
|||
|
||||
if ($result = @pg_query($this->db_connect_id, "EXPLAIN $explain_query"))
|
||||
{
|
||||
while ($row = @pg_fetch_assoc($result, null))
|
||||
while ($row = pg_fetch_assoc($result, null))
|
||||
{
|
||||
$html_table = $this->sql_report('add_select_row', $query, $html_table, $row);
|
||||
}
|
||||
pg_free_result($result);
|
||||
}
|
||||
@pg_free_result($result);
|
||||
|
||||
if ($html_table)
|
||||
{
|
||||
|
@ -460,11 +468,14 @@ class postgres extends \phpbb\db\driver\driver
|
|||
$endtime = $endtime[0] + $endtime[1];
|
||||
|
||||
$result = @pg_query($this->db_connect_id, $query);
|
||||
while ($void = @pg_fetch_assoc($result, null))
|
||||
if ($result)
|
||||
{
|
||||
while ($void = pg_fetch_assoc($result, null))
|
||||
{
|
||||
// Take the time spent on parsing rows into account
|
||||
}
|
||||
@pg_free_result($result);
|
||||
pg_free_result($result);
|
||||
}
|
||||
|
||||
$splittime = explode(' ', microtime());
|
||||
$splittime = $splittime[0] + $splittime[1];
|
||||
|
|
|
@ -70,7 +70,9 @@ class sqlite extends \phpbb\db\driver\driver
|
|||
if (!$use_cache || empty($cache) || ($this->sql_server_version = $cache->get('sqlite_version')) === false)
|
||||
{
|
||||
$result = @sqlite_query('SELECT sqlite_version() AS version', $this->db_connect_id);
|
||||
$row = @sqlite_fetch_array($result, SQLITE_ASSOC);
|
||||
if ($result)
|
||||
{
|
||||
$row = sqlite_fetch_array($result, SQLITE_ASSOC);
|
||||
|
||||
$this->sql_server_version = (!empty($row['version'])) ? $row['version'] : 0;
|
||||
|
||||
|
@ -79,6 +81,7 @@ class sqlite extends \phpbb\db\driver\driver
|
|||
$cache->put('sqlite_version', $this->sql_server_version);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ($raw) ? $this->sql_server_version : 'SQLite ' . $this->sql_server_version;
|
||||
}
|
||||
|
@ -137,15 +140,15 @@ class sqlite extends \phpbb\db\driver\driver
|
|||
$this->sql_report('stop', $query);
|
||||
}
|
||||
|
||||
if (!$this->query_result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($cache && $cache_ttl)
|
||||
{
|
||||
$this->open_queries[(int) $this->query_result] = $this->query_result;
|
||||
$this->query_result = $cache->sql_save($this, $query, $this->query_result, $cache_ttl);
|
||||
}
|
||||
else if (strpos($query, 'SELECT') === 0 && $this->query_result)
|
||||
{
|
||||
$this->open_queries[(int) $this->query_result] = $this->query_result;
|
||||
}
|
||||
}
|
||||
else if (defined('DEBUG'))
|
||||
{
|
||||
|
@ -203,7 +206,7 @@ class sqlite extends \phpbb\db\driver\driver
|
|||
return $cache->sql_fetchrow($query_id);
|
||||
}
|
||||
|
||||
return ($query_id !== false) ? @sqlite_fetch_array($query_id, SQLITE_ASSOC) : false;
|
||||
return ($query_id) ? sqlite_fetch_array($query_id, SQLITE_ASSOC) : false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -223,7 +226,7 @@ class sqlite extends \phpbb\db\driver\driver
|
|||
return $cache->sql_rowseek($rownum, $query_id);
|
||||
}
|
||||
|
||||
return ($query_id !== false) ? @sqlite_seek($query_id, $rownum) : false;
|
||||
return ($query_id) ? @sqlite_seek($query_id, $rownum) : false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -337,10 +340,13 @@ class sqlite extends \phpbb\db\driver\driver
|
|||
$endtime = $endtime[0] + $endtime[1];
|
||||
|
||||
$result = @sqlite_query($query, $this->db_connect_id);
|
||||
while ($void = @sqlite_fetch_array($result, SQLITE_ASSOC))
|
||||
if ($result)
|
||||
{
|
||||
while ($void = sqlite_fetch_array($result, SQLITE_ASSOC))
|
||||
{
|
||||
// Take the time spent on parsing rows into account
|
||||
}
|
||||
}
|
||||
|
||||
$splittime = explode(' ', microtime());
|
||||
$splittime = $splittime[0] + $splittime[1];
|
||||
|
|
|
@ -50,7 +50,7 @@ class sqlite3 extends \phpbb\db\driver\driver
|
|||
$this->dbo = new \SQLite3($this->server, SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE);
|
||||
$this->db_connect_id = true;
|
||||
}
|
||||
catch (Exception $e)
|
||||
catch (\Exception $e)
|
||||
{
|
||||
return array('message' => $e->getMessage());
|
||||
}
|
||||
|
@ -138,6 +138,11 @@ class sqlite3 extends \phpbb\db\driver\driver
|
|||
$this->sql_report('stop', $query);
|
||||
}
|
||||
|
||||
if (!$this->query_result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($cache && $cache_ttl)
|
||||
{
|
||||
$this->query_result = $cache->sql_save($this, $query, $this->query_result, $cache_ttl);
|
||||
|
@ -362,10 +367,13 @@ class sqlite3 extends \phpbb\db\driver\driver
|
|||
$endtime = $endtime[0] + $endtime[1];
|
||||
|
||||
$result = $this->dbo->query($query);
|
||||
if ($result)
|
||||
{
|
||||
while ($void = $result->fetchArray(SQLITE3_ASSOC))
|
||||
{
|
||||
// Take the time spent on parsing rows into account
|
||||
}
|
||||
}
|
||||
|
||||
$splittime = explode(' ', microtime());
|
||||
$splittime = $splittime[0] + $splittime[1];
|
||||
|
|
Loading…
Add table
Reference in a new issue