aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes
diff options
context:
space:
mode:
authorDavid M <davidmj@users.sourceforge.net>2007-04-08 09:43:21 +0000
committerDavid M <davidmj@users.sourceforge.net>2007-04-08 09:43:21 +0000
commit539ac00f02f24266f598fb746b2e145e1ec46182 (patch)
treea2316905f1d6d8ee083dce4f8c48320d47085262 /phpBB/includes
parent4f5cf86db9fa7f4525480355b73e4f63f321a3fb (diff)
downloadforums-539ac00f02f24266f598fb746b2e145e1ec46182.tar
forums-539ac00f02f24266f598fb746b2e145e1ec46182.tar.gz
forums-539ac00f02f24266f598fb746b2e145e1ec46182.tar.bz2
forums-539ac00f02f24266f598fb746b2e145e1ec46182.tar.xz
forums-539ac00f02f24266f598fb746b2e145e1ec46182.zip
- (x)HTML bug
- added functionality for MySQL 5.0.37+ (on the community branch), EXPLAIN is now more detailed. To reap full benefits, use *NIX OS. This may or may not stay git-svn-id: file:///svn/phpbb/trunk@7301 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes')
-rw-r--r--phpBB/includes/db/dbal.php1
-rw-r--r--phpBB/includes/db/mysql.php59
-rw-r--r--phpBB/includes/db/mysqli.php60
3 files changed, 120 insertions, 0 deletions
diff --git a/phpBB/includes/db/dbal.php b/phpBB/includes/db/dbal.php
index 80fa1322e9..dbc0859733 100644
--- a/phpBB/includes/db/dbal.php
+++ b/phpBB/includes/db/dbal.php
@@ -626,6 +626,7 @@ class dbal
<tr>
<td class="row3"><textarea style="font-family:\'Courier New\',monospace;width:99%" rows="5" cols="10">' . preg_replace('/\t(AND|OR)(\W)/', "\$1\$2", htmlspecialchars(preg_replace('/[\s]*[\n\r\t]+[\n\r\s\t]*/', "\n", $query))) . '</textarea></td>
</tr>
+ </tbody>
</table>
' . $this->html_hold . '
diff --git a/phpBB/includes/db/mysql.php b/phpBB/includes/db/mysql.php
index 2eb3a561bc..dfa4823a87 100644
--- a/phpBB/includes/db/mysql.php
+++ b/phpBB/includes/db/mysql.php
@@ -326,6 +326,22 @@ class dbal_mysql extends dbal
*/
function _sql_report($mode, $query = '')
{
+ static $test_prof;
+
+ // current detection method, might just switch to see the existance of INFORMATION_SCHEMA.PROFILING
+ if ($test_prof === null)
+ {
+ $test_prof = false;
+ if (strpos($this->mysql_version, 'community') !== false)
+ {
+ $ver = substr($this->mysql_version, 0, strpos($this->mysql_version, '-'));
+ if (version_compare($ver, '5.0.37', '>=') && version_compare($ver, '5.1', '<'))
+ {
+ $test_prof = true;
+ }
+ }
+ }
+
switch ($mode)
{
case 'start':
@@ -344,6 +360,12 @@ class dbal_mysql extends dbal
{
$html_table = false;
+ // begin profiling
+ if ($test_prof)
+ {
+ @mysql_query('SET profiling = 1;', $this->db_connect_id);
+ }
+
if ($result = @mysql_query("EXPLAIN $explain_query", $this->db_connect_id))
{
while ($row = @mysql_fetch_assoc($result))
@@ -357,6 +379,43 @@ class dbal_mysql extends dbal
{
$this->html_hold .= '</table>';
}
+
+ if ($test_prof)
+ {
+ $html_table = false;
+
+ // get the last profile
+ if ($result = @mysql_query('SHOW PROFILE ALL;', $this->db_connect_id))
+ {
+ $this->html_hold .= '<br />';
+ while ($row = @mysql_fetch_assoc($result))
+ {
+ // make <unknown> HTML safe
+ if (!empty($row['Source_function']))
+ {
+ $row['Source_function'] = str_replace(array('<', '>'), array('&lt;', '&gt;'), $row['Source_function']);
+ }
+
+ // remove unsupported features
+ foreach ($row as $key => $val)
+ {
+ if ($val === null)
+ {
+ unset($row[$key]);
+ }
+ }
+ $html_table = $this->sql_report('add_select_row', $query, $html_table, $row);
+ }
+ }
+ @mysql_free_result($result);
+
+ if ($html_table)
+ {
+ $this->html_hold .= '</table>';
+ }
+
+ @mysql_query('SET profiling = 0;', $this->db_connect_id);
+ }
}
break;
diff --git a/phpBB/includes/db/mysqli.php b/phpBB/includes/db/mysqli.php
index 3149349411..c03c117085 100644
--- a/phpBB/includes/db/mysqli.php
+++ b/phpBB/includes/db/mysqli.php
@@ -294,6 +294,22 @@ class dbal_mysqli extends dbal
*/
function _sql_report($mode, $query = '')
{
+ static $test_prof;
+
+ // current detection method, might just switch to see the existance of INFORMATION_SCHEMA.PROFILING
+ if ($test_prof === null)
+ {
+ $test_prof = false;
+ if (strpos(mysqli_get_server_info($this->db_connect_id), 'community') !== false)
+ {
+ $ver = mysqli_get_server_version($this->db_connect_id);
+ if ($ver >= 50037 && $ver < 51000)
+ {
+ $test_prof = true;
+ }
+ }
+ }
+
switch ($mode)
{
case 'start':
@@ -312,6 +328,12 @@ class dbal_mysqli extends dbal
{
$html_table = false;
+ // begin profiling
+ if ($test_prof)
+ {
+ @mysqli_query($this->db_connect_id, 'SET profiling = 1;');
+ }
+
if ($result = @mysqli_query($this->db_connect_id, "EXPLAIN $explain_query"))
{
while ($row = @mysqli_fetch_assoc($result))
@@ -325,6 +347,43 @@ class dbal_mysqli extends dbal
{
$this->html_hold .= '</table>';
}
+
+ if ($test_prof)
+ {
+ $html_table = false;
+
+ // get the last profile
+ if ($result = @mysqli_query($this->db_connect_id, 'SHOW PROFILE ALL;'))
+ {
+ $this->html_hold .= '<br />';
+ while ($row = @mysqli_fetch_assoc($result))
+ {
+ // make <unknown> HTML safe
+ if (!empty($row['Source_function']))
+ {
+ $row['Source_function'] = str_replace(array('<', '>'), array('&lt;', '&gt;'), $row['Source_function']);
+ }
+
+ // remove unsupported features
+ foreach ($row as $key => $val)
+ {
+ if ($val === null)
+ {
+ unset($row[$key]);
+ }
+ }
+ $html_table = $this->sql_report('add_select_row', $query, $html_table, $row);
+ }
+ }
+ @mysqli_free_result($result);
+
+ if ($html_table)
+ {
+ $this->html_hold .= '</table>';
+ }
+
+ @mysqli_query($this->db_connect_id, 'SET profiling = 0;');
+ }
}
break;
@@ -347,6 +406,7 @@ class dbal_mysqli extends dbal
break;
}
+ @mysqli_query($this->db_connect_id, "SET profiling = 0;");
}
}