aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/db/mysql4.php
diff options
context:
space:
mode:
authorMeik Sievertsen <acydburn@phpbb.com>2005-10-02 18:18:52 +0000
committerMeik Sievertsen <acydburn@phpbb.com>2005-10-02 18:18:52 +0000
commit1d688c6b8de0073e637be7601e0efbd5947bce00 (patch)
treec9a3e8e11c224cf3ce0fdfde05e02e12ecdfb19c /phpBB/includes/db/mysql4.php
parent1a18e36684d74d5a0c2538805a3ff8436036189e (diff)
downloadforums-1d688c6b8de0073e637be7601e0efbd5947bce00.tar
forums-1d688c6b8de0073e637be7601e0efbd5947bce00.tar.gz
forums-1d688c6b8de0073e637be7601e0efbd5947bce00.tar.bz2
forums-1d688c6b8de0073e637be7601e0efbd5947bce00.tar.xz
forums-1d688c6b8de0073e637be7601e0efbd5947bce00.zip
- add building multi insert to dbal
- fix sql explain in mysql4 layer git-svn-id: file:///svn/phpbb/trunk@5242 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/db/mysql4.php')
-rw-r--r--phpBB/includes/db/mysql4.php42
1 files changed, 21 insertions, 21 deletions
diff --git a/phpBB/includes/db/mysql4.php b/phpBB/includes/db/mysql4.php
index df176db329..6d3438006f 100644
--- a/phpBB/includes/db/mysql4.php
+++ b/phpBB/includes/db/mysql4.php
@@ -20,11 +20,14 @@ if (!defined('SQL_LAYER'))
/**
* @package dbal
* MySQL4 Database Abstraction Layer
-* Minimum Requirement is 4.0+/4.1+
+* Minimum Requirement is 4.0+ (4.1+ compatible)
*/
class dbal_mysql4 extends dbal
{
+ /**
+ * Connect to sql server
+ */
function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false)
{
$this->persistency = $persistency;
@@ -319,15 +322,12 @@ class dbal_mysql4 extends dbal
function _sql_report($mode, $query = '')
{
global $cache, $starttime, $phpbb_root_path;
- static $curtime, $query_hold, $html_hold;
- static $sql_report = '';
- static $cache_num_queries = 0;
switch ($mode)
{
case 'start':
- $query_hold = $query;
- $html_hold = '';
+ $this->query_hold = $query;
+ $this->html_hold = '';
$explain_query = $query;
if (preg_match('/UPDATE ([a-z0-9_]+).*?WHERE(.*)/s', $query, $m))
@@ -341,7 +341,7 @@ class dbal_mysql4 extends dbal
if (preg_match('/^SELECT/', $explain_query))
{
- $html_table = FALSE;
+ $html_table = false;
if ($result = mysql_query("EXPLAIN $explain_query", $this->db_connect_id))
{
@@ -349,35 +349,35 @@ class dbal_mysql4 extends dbal
{
if (!$html_table && sizeof($row))
{
- $html_table = TRUE;
- $html_hold .= '<table class="bg" width="100%" cellspacing="1" cellpadding="4" border="0" align="center"><tr>';
+ $html_table = true;
+ $this->html_hold .= '<table class="bg" width="100%" cellspacing="1" cellpadding="4" border="0" align="center"><tr>';
foreach (array_keys($row) as $val)
{
- $html_hold .= '<th nowrap="nowrap">' . (($val) ? ucwords(str_replace('_', ' ', $val)) : '&nbsp;') . '</th>';
+ $this->html_hold .= '<th nowrap="nowrap">' . (($val) ? ucwords(str_replace('_', ' ', $val)) : '&nbsp;') . '</th>';
}
- $html_hold .= '</tr>';
+ $this->html_hold .= '</tr>';
}
- $html_hold .= '<tr>';
+ $this->html_hold .= '<tr>';
$class = 'row1';
foreach (array_values($row) as $val)
{
$class = ($class == 'row1') ? 'row2' : 'row1';
- $html_hold .= '<td class="' . $class . '">' . (($val) ? $val : '&nbsp;') . '</td>';
+ $this->html_hold .= '<td class="' . $class . '">' . (($val) ? $val : '&nbsp;') . '</td>';
}
- $html_hold .= '</tr>';
+ $this->html_hold .= '</tr>';
}
}
if ($html_table)
{
- $html_hold .= '</table>';
+ $this->html_hold .= '</table>';
}
}
- $curtime = explode(' ', microtime());
- $curtime = $curtime[0] + $curtime[1];
+ $this->curtime = explode(' ', microtime());
+ $this->curtime = $this->curtime[0] + $this->curtime[1];
break;
case 'fromcache':
@@ -392,19 +392,19 @@ class dbal_mysql4 extends dbal
$splittime = explode(' ', microtime());
$splittime = $splittime[0] + $splittime[1];
- $time_cache = $endtime - $curtime;
+ $time_cache = $endtime - $this->curtime;
$time_db = $splittime - $endtime;
$color = ($time_db > $time_cache) ? 'green' : 'red';
- $sql_report .= '<hr width="100%"/><br /><table class="bg" width="100%" cellspacing="1" cellpadding="4" border="0"><tr><th>Query results obtained from the cache</th></tr><tr><td class="row1"><textarea style="font-family:\'Courier New\',monospace;width:100%" rows="5">' . preg_replace('/\t(AND|OR)(\W)/', "\$1\$2", htmlspecialchars(preg_replace('/[\s]*[\n\r\t]+[\n\r\s\t]*/', "\n", $query))) . '</textarea></td></tr></table><p align="center">';
+ $this->sql_report .= '<hr width="100%"/><br /><table class="bg" width="100%" cellspacing="1" cellpadding="4" border="0"><tr><th>Query results obtained from the cache</th></tr><tr><td class="row1"><textarea style="font-family:\'Courier New\',monospace;width:100%" rows="5">' . preg_replace('/\t(AND|OR)(\W)/', "\$1\$2", htmlspecialchars(preg_replace('/[\s]*[\n\r\t]+[\n\r\s\t]*/', "\n", $query))) . '</textarea></td></tr></table><p align="center">';
- $sql_report .= 'Before: ' . sprintf('%.5f', $curtime - $starttime) . 's | After: ' . sprintf('%.5f', $endtime - $starttime) . 's | Elapsed [cache]: <b style="color: ' . $color . '">' . sprintf('%.5f', ($time_cache)) . 's</b> | Elapsed [db]: <b>' . sprintf('%.5f', $time_db) . 's</b></p>';
+ $this->sql_report .= 'Before: ' . sprintf('%.5f', $this->curtime - $starttime) . 's | After: ' . sprintf('%.5f', $endtime - $starttime) . 's | Elapsed [cache]: <b style="color: ' . $color . '">' . sprintf('%.5f', ($time_cache)) . 's</b> | Elapsed [db]: <b>' . sprintf('%.5f', $time_db) . 's</b></p>';
// Pad the start time to not interfere with page timing
$starttime += $time_db;
mysql_free_result($result);
- $cache_num_queries++;
+ $this->cache_num_queries++;
break;
}
}