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