|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
*
|
|
|
ef5584 |
* @package dbal
|
|
|
ef5584 |
* @version $Id: mysql.php 8815 2008-09-04 13:37:01Z acydburn $
|
|
|
ef5584 |
* @copyright (c) 2005 phpBB Group
|
|
|
ef5584 |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
|
|
ef5584 |
*
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* @ignore
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
if (!defined('IN_PHPBB'))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
exit;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx);
|
|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* MySQL4 Database Abstraction Layer
|
|
|
ef5584 |
* Compatible with:
|
|
|
ef5584 |
* MySQL 3.23+
|
|
|
ef5584 |
* MySQL 4.0+
|
|
|
ef5584 |
* MySQL 4.1+
|
|
|
ef5584 |
* MySQL 5.0+
|
|
|
ef5584 |
* @package dbal
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
class dbal_mysql extends dbal
|
|
|
ef5584 |
{
|
|
|
ef5584 |
var $multi_insert = true;
|
|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* Connect to server
|
|
|
ef5584 |
* @access public
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$this->persistency = $persistency;
|
|
|
ef5584 |
$this->user = $sqluser;
|
|
|
ef5584 |
$this->server = $sqlserver . (($port) ? ':' . $port : '');
|
|
|
ef5584 |
$this->dbname = $database;
|
|
|
ef5584 |
|
|
|
ef5584 |
$this->sql_layer = 'mysql4';
|
|
|
ef5584 |
|
|
|
ef5584 |
$this->db_connect_id = ($this->persistency) ? @mysql_pconnect($this->server, $this->user, $sqlpassword, $new_link) : @mysql_connect($this->server, $this->user, $sqlpassword, $new_link);
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($this->db_connect_id && $this->dbname != '')
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if (@mysql_select_db($this->dbname, $this->db_connect_id))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
// Determine what version we are using and if it natively supports UNICODE
|
|
|
ef5584 |
if (version_compare($this->sql_server_info(true), '4.1.3', '>='))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
@mysql_query("SET NAMES 'utf8'", $this->db_connect_id);
|
|
|
ef5584 |
|
|
|
ef5584 |
// enforce strict mode on databases that support it
|
|
|
ef5584 |
if (version_compare($this->sql_server_info(true), '5.0.2', '>='))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$result = @mysql_query('SELECT @@session.sql_mode AS sql_mode', $this->db_connect_id);
|
|
|
ef5584 |
$row = @mysql_fetch_assoc($result);
|
|
|
ef5584 |
@mysql_free_result($result);
|
|
|
ef5584 |
$modes = array_map('trim', explode(',', $row['sql_mode']));
|
|
|
ef5584 |
|
|
|
ef5584 |
// TRADITIONAL includes STRICT_ALL_TABLES and STRICT_TRANS_TABLES
|
|
|
ef5584 |
if (!in_array('TRADITIONAL', $modes))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if (!in_array('STRICT_ALL_TABLES', $modes))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$modes[] = 'STRICT_ALL_TABLES';
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!in_array('STRICT_TRANS_TABLES', $modes))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$modes[] = 'STRICT_TRANS_TABLES';
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$mode = implode(',', $modes);
|
|
|
ef5584 |
@mysql_query("SET SESSION sql_mode='{$mode}'", $this->db_connect_id);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else if (version_compare($this->sql_server_info(true), '4.0.0', '<'))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$this->sql_layer = 'mysql';
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
return $this->db_connect_id;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
return $this->sql_error('');
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* Version information about used database
|
|
|
ef5584 |
* @param bool $raw if true, only return the fetched sql_server_version
|
|
|
ef5584 |
* @return string sql server version
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
function sql_server_info($raw = false)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
global $cache;
|
|
|
ef5584 |
|
|
|
ef5584 |
if (empty($cache) || ($this->sql_server_version = $cache->get('mysql_version')) === false)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$result = @mysql_query('SELECT VERSION() AS version', $this->db_connect_id);
|
|
|
ef5584 |
$row = @mysql_fetch_assoc($result);
|
|
|
ef5584 |
@mysql_free_result($result);
|
|
|
ef5584 |
|
|
|
ef5584 |
$this->sql_server_version = $row['version'];
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!empty($cache))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$cache->put('mysql_version', $this->sql_server_version);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
return ($raw) ? $this->sql_server_version : 'MySQL ' . $this->sql_server_version;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* SQL Transaction
|
|
|
ef5584 |
* @access private
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
function _sql_transaction($status = 'begin')
|
|
|
ef5584 |
{
|
|
|
ef5584 |
switch ($status)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
case 'begin':
|
|
|
ef5584 |
return @mysql_query('BEGIN', $this->db_connect_id);
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
|
|
|
ef5584 |
case 'commit':
|
|
|
ef5584 |
return @mysql_query('COMMIT', $this->db_connect_id);
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
|
|
|
ef5584 |
case 'rollback':
|
|
|
ef5584 |
return @mysql_query('ROLLBACK', $this->db_connect_id);
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
return true;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* Base query method
|
|
|
ef5584 |
*
|
|
|
ef5584 |
* @param string $query Contains the SQL query which shall be executed
|
|
|
ef5584 |
* @param int $cache_ttl Either 0 to avoid caching or the time in seconds which the result shall be kept in cache
|
|
|
ef5584 |
* @return mixed When casted to bool the returned value returns true on success and false on failure
|
|
|
ef5584 |
*
|
|
|
ef5584 |
* @access public
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
function sql_query($query = '', $cache_ttl = 0)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if ($query != '')
|
|
|
ef5584 |
{
|
|
|
ef5584 |
global $cache;
|
|
|
ef5584 |
|
|
|
ef5584 |
// EXPLAIN only in extra debug mode
|
|
|
ef5584 |
if (defined('DEBUG_EXTRA'))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$this->sql_report('start', $query);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$this->query_result = ($cache_ttl && method_exists($cache, 'sql_load')) ? $cache->sql_load($query) : false;
|
|
|
ef5584 |
$this->sql_add_num_queries($this->query_result);
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($this->query_result === false)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if (($this->query_result = @mysql_query($query, $this->db_connect_id)) === false)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$this->sql_error($query);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if (defined('DEBUG_EXTRA'))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$this->sql_report('stop', $query);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($cache_ttl && method_exists($cache, 'sql_save'))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$this->open_queries[(int) $this->query_result] = $this->query_result;
|
|
|
ef5584 |
$cache->sql_save($query, $this->query_result, $cache_ttl);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else if (strpos($query, 'SELECT') === 0 && $this->query_result)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$this->open_queries[(int) $this->query_result] = $this->query_result;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else if (defined('DEBUG_EXTRA'))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$this->sql_report('fromcache', $query);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
return false;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
return $this->query_result;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* Build LIMIT query
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
function _sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$this->query_result = false;
|
|
|
ef5584 |
|
|
|
ef5584 |
// if $total is set to 0 we do not want to limit the number of rows
|
|
|
ef5584 |
if ($total == 0)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
// Having a value of -1 was always a bug
|
|
|
ef5584 |
$total = '18446744073709551615';
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$query .= "\n LIMIT " . ((!empty($offset)) ? $offset . ', ' . $total : $total);
|
|
|
ef5584 |
|
|
|
ef5584 |
return $this->sql_query($query, $cache_ttl);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* Return number of affected rows
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
function sql_affectedrows()
|
|
|
ef5584 |
{
|
|
|
ef5584 |
return ($this->db_connect_id) ? @mysql_affected_rows($this->db_connect_id) : false;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* Fetch current row
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
function sql_fetchrow($query_id = false)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
global $cache;
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($query_id === false)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$query_id = $this->query_result;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if (isset($cache->sql_rowset[$query_id]))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
return $cache->sql_fetchrow($query_id);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
return ($query_id !== false) ? @mysql_fetch_assoc($query_id) : false;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* Seek to given row number
|
|
|
ef5584 |
* rownum is zero-based
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
function sql_rowseek($rownum, &$query_id)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
global $cache;
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($query_id === false)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$query_id = $this->query_result;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if (isset($cache->sql_rowset[$query_id]))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
return $cache->sql_rowseek($rownum, $query_id);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
return ($query_id !== false) ? @mysql_data_seek($query_id, $rownum) : false;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* Get last inserted id after insert statement
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
function sql_nextid()
|
|
|
ef5584 |
{
|
|
|
ef5584 |
return ($this->db_connect_id) ? @mysql_insert_id($this->db_connect_id) : false;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* Free sql result
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
function sql_freeresult($query_id = false)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
global $cache;
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($query_id === false)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$query_id = $this->query_result;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if (isset($cache->sql_rowset[$query_id]))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
return $cache->sql_freeresult($query_id);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if (isset($this->open_queries[(int) $query_id]))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
unset($this->open_queries[(int) $query_id]);
|
|
|
ef5584 |
return @mysql_free_result($query_id);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
return false;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* Escape string used in sql query
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
function sql_escape($msg)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if (!$this->db_connect_id)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
return @mysql_real_escape_string($msg);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
return @mysql_real_escape_string($msg, $this->db_connect_id);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* Build LIKE expression
|
|
|
ef5584 |
* @access private
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
function _sql_like_expression($expression)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
return $expression;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* Build db-specific query data
|
|
|
ef5584 |
* @access private
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
function _sql_custom_build($stage, $data)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
switch ($stage)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
case 'FROM':
|
|
|
ef5584 |
$data = '(' . $data . ')';
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
return $data;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* return sql error array
|
|
|
ef5584 |
* @access private
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
function _sql_error()
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if (!$this->db_connect_id)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
return array(
|
|
|
ef5584 |
'message' => @mysql_error(),
|
|
|
ef5584 |
'code' => @mysql_errno()
|
|
|
ef5584 |
);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
return array(
|
|
|
ef5584 |
'message' => @mysql_error($this->db_connect_id),
|
|
|
ef5584 |
'code' => @mysql_errno($this->db_connect_id)
|
|
|
ef5584 |
);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* Close sql connection
|
|
|
ef5584 |
* @access private
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
function _sql_close()
|
|
|
ef5584 |
{
|
|
|
ef5584 |
return @mysql_close($this->db_connect_id);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* Build db-specific report
|
|
|
ef5584 |
* @access private
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
function _sql_report($mode, $query = '')
|
|
|
ef5584 |
{
|
|
|
ef5584 |
static $test_prof;
|
|
|
ef5584 |
|
|
|
ef5584 |
// current detection method, might just switch to see the existance of INFORMATION_SCHEMA.PROFILING
|
|
|
ef5584 |
if ($test_prof === null)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$test_prof = false;
|
|
|
ef5584 |
if (version_compare($this->sql_server_info(true), '5.0.37', '>=') && version_compare($this->sql_server_info(true), '5.1', '<'))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$test_prof = true;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
switch ($mode)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
case 'start':
|
|
|
ef5584 |
|
|
|
ef5584 |
$explain_query = $query;
|
|
|
ef5584 |
if (preg_match('/UPDATE ([a-z0-9_]+).*?WHERE(.*)/s', $query, $m))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$explain_query = 'SELECT * FROM ' . $m[1] . ' WHERE ' . $m[2];
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else if (preg_match('/DELETE FROM ([a-z0-9_]+).*?WHERE(.*)/s', $query, $m))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$explain_query = 'SELECT * FROM ' . $m[1] . ' WHERE ' . $m[2];
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if (preg_match('/^SELECT/', $explain_query))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$html_table = false;
|
|
|
ef5584 |
|
|
|
ef5584 |
// begin profiling
|
|
|
ef5584 |
if ($test_prof)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
@mysql_query('SET profiling = 1;', $this->db_connect_id);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($result = @mysql_query("EXPLAIN $explain_query", $this->db_connect_id))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
while ($row = @mysql_fetch_assoc($result))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$html_table = $this->sql_report('add_select_row', $query, $html_table, $row);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
@mysql_free_result($result);
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($html_table)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$this->html_hold .= '';
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($test_prof)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$html_table = false;
|
|
|
ef5584 |
|
|
|
ef5584 |
// get the last profile
|
|
|
ef5584 |
if ($result = @mysql_query('SHOW PROFILE ALL;', $this->db_connect_id))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$this->html_hold .= ' ';
|
|
|
ef5584 |
while ($row = @mysql_fetch_assoc($result))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
// make <unknown> HTML safe
|
|
|
ef5584 |
if (!empty($row['Source_function']))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$row['Source_function'] = str_replace(array('<', '>'), array('<', '>'), $row['Source_function']);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// remove unsupported features
|
|
|
ef5584 |
foreach ($row as $key => $val)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if ($val === null)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
unset($row[$key]);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
$html_table = $this->sql_report('add_select_row', $query, $html_table, $row);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
@mysql_free_result($result);
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($html_table)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$this->html_hold .= '';
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
@mysql_query('SET profiling = 0;', $this->db_connect_id);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
|
|
|
ef5584 |
case 'fromcache':
|
|
|
ef5584 |
$endtime = explode(' ', microtime());
|
|
|
ef5584 |
$endtime = $endtime[0] + $endtime[1];
|
|
|
ef5584 |
|
|
|
ef5584 |
$result = @mysql_query($query, $this->db_connect_id);
|
|
|
ef5584 |
while ($void = @mysql_fetch_assoc($result))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
// Take the time spent on parsing rows into account
|
|
|
ef5584 |
}
|
|
|
ef5584 |
@mysql_free_result($result);
|
|
|
ef5584 |
|
|
|
ef5584 |
$splittime = explode(' ', microtime());
|
|
|
ef5584 |
$splittime = $splittime[0] + $splittime[1];
|
|
|
ef5584 |
|
|
|
ef5584 |
$this->sql_report('record_fromcache', $query, $endtime, $splittime);
|
|
|
ef5584 |
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
?>
|