1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-19 15:01:33 +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:
Joas Schilling
2014-08-07 12:09:01 +02:00
13 changed files with 261 additions and 153 deletions

View File

@@ -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;
@@ -181,12 +181,17 @@ class mssql_odbc extends \phpbb\db\driver\mssql_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;
}
@@ -261,7 +266,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;
}
/**
@@ -273,13 +278,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;
@@ -305,7 +310,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;
@@ -360,11 +365,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)
{
// Take the time spent on parsing rows into account
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];