mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-01 14:30:32 +02:00
Merge pull request #2637 from Nicofuma/ticket/12387
[ticket/12387] Cleanup *_free_result call and remove @ on that call * Nicofuma/ticket/12387: [ticket/12387] Fix a call to sql_freeresult in full_text_native [ticket/12387] Fix \phpbb\db\driver\mysqli::sql_freeresult [ticket/12387] Use the hash as query_id for caching [ticket/12387] Remove unnecessary checks [ticket/12387] mssql_query return true if a select query returns 0 row [ticket/12387] Cleanup *_free_result call and remove @ on that call
This commit is contained in:
@@ -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);
|
||||
$modes = array_map('trim', explode(',', $row['sql_mode']));
|
||||
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,14 +121,17 @@ 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);
|
||||
|
||||
$this->sql_server_version = $row['version'];
|
||||
|
||||
if (!empty($cache) && $use_cache)
|
||||
if ($result)
|
||||
{
|
||||
$cache->put('mysql_version', $this->sql_server_version);
|
||||
$row = mysql_fetch_assoc($result);
|
||||
mysql_free_result($result);
|
||||
|
||||
$this->sql_server_version = $row['version'];
|
||||
|
||||
if (!empty($cache) && $use_cache)
|
||||
{
|
||||
$cache->put('mysql_version', $this->sql_server_version);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,12 +200,17 @@ class mysql extends \phpbb\db\driver\mysql_base
|
||||
$this->sql_time += microtime(true) - $this->curtime;
|
||||
}
|
||||
|
||||
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)
|
||||
else if (strpos($query, 'SELECT') === 0)
|
||||
{
|
||||
$this->open_queries[(int) $this->query_result] = $this->query_result;
|
||||
}
|
||||
@@ -257,7 +272,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;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -308,7 +323,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;
|
||||
@@ -411,12 +426,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)
|
||||
{
|
||||
@@ -431,7 +446,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']))
|
||||
@@ -449,8 +464,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)
|
||||
{
|
||||
@@ -468,11 +483,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)
|
||||
{
|
||||
// Take the time spent on parsing rows into account
|
||||
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];
|
||||
|
Reference in New Issue
Block a user