diff options
author | Meik Sievertsen <acydburn@phpbb.com> | 2005-04-22 17:44:36 +0000 |
---|---|---|
committer | Meik Sievertsen <acydburn@phpbb.com> | 2005-04-22 17:44:36 +0000 |
commit | d1f3349f7b7cd7816c125cf83616db154a43b8b1 (patch) | |
tree | 4cdc88656f2bacaabe49fe72723b75e1a7e8a286 /phpBB/includes/db/mssql-odbc.php | |
parent | f0d7d05888222699f2cadb04c9b0cb3123aed2d9 (diff) | |
download | forums-d1f3349f7b7cd7816c125cf83616db154a43b8b1.tar forums-d1f3349f7b7cd7816c125cf83616db154a43b8b1.tar.gz forums-d1f3349f7b7cd7816c125cf83616db154a43b8b1.tar.bz2 forums-d1f3349f7b7cd7816c125cf83616db154a43b8b1.tar.xz forums-d1f3349f7b7cd7816c125cf83616db154a43b8b1.zip |
- dbal changes
git-svn-id: file:///svn/phpbb/trunk@5130 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/db/mssql-odbc.php')
-rw-r--r-- | phpBB/includes/db/mssql-odbc.php | 99 |
1 files changed, 9 insertions, 90 deletions
diff --git a/phpBB/includes/db/mssql-odbc.php b/phpBB/includes/db/mssql-odbc.php index 5645827472..9fb49837d1 100644 --- a/phpBB/includes/db/mssql-odbc.php +++ b/phpBB/includes/db/mssql-odbc.php @@ -387,9 +387,9 @@ class sql_db if ($query_id) { - if ($row < $this->num_rows[$query_id]) + if ($rownum < $this->num_rows[$query_id]) { - $getrow = ($row == -1) ? $this->current_row[$query_id] - 1 : $row; + $getrow = ($rownum == -1) ? $this->current_row[$query_id] - 1 : $rownum; return $this->result_rowset[$query_id][$getrow][$this->field_names[$query_id][$field]]; } @@ -407,7 +407,7 @@ class sql_db if (isset($this->current_row[$query_id])) { - $this->current_row[$query_id] = $offset - 1; + $this->current_row[$query_id] = $rownum; return true; } @@ -419,36 +419,6 @@ class sql_db return ($this->next_id[$this->db_connect_id]) ? $this->next_id[$this->db_connect_id] : false; } - function sql_numfields($query_id = false) - { - if (!$query_id) - { - $query_id = $this->query_result; - } - - return ($query_id) ? sizeof($this->field_names[$query_id]) : false; - } - - function sql_fieldname($offset, $query_id = false) - { - if (!$query_id) - { - $query_id = $this->query_result; - } - - return ($query_id) ? $this->field_names[$query_id][$offset] : false; - } - - function sql_fieldtype($offset, $query_id = false) - { - if (!$query_id) - { - $query_id = $this->query_result; - } - - return ($query_id) ? $this->field_types[$query_id][$offset] : false; - } - function sql_freeresult($query_id = false) { if (!$query_id) @@ -508,7 +478,7 @@ class sql_db return; } - global $db, $cache, $starttime, $phpbb_root_path; + global $cache, $starttime, $phpbb_root_path; static $curtime, $query_hold, $html_hold; static $sql_report = ''; static $cache_num_queries = 0; @@ -525,7 +495,7 @@ class sql_db { $cache->unload(); } - $db->sql_close(); + $this->sql_close(); $mtime = explode(' ', microtime()); $totaltime = $mtime[0] + $mtime[1] - $starttime; @@ -534,7 +504,7 @@ class sql_db echo 'th { background-image: url(\'' . $phpbb_root_path . 'adm/images/cellpic3.gif\') }' . "\n"; echo 'td.cat { background-image: url(\'' . $phpbb_root_path . 'adm/images/cellpic1.gif\') }' . "\n"; echo '</style><title>' . $msg_title . '</title></head><body>'; - echo '<table width="100%" cellspacing="0" cellpadding="0" border="0"><tr><td><a href="' . htmlspecialchars(preg_replace('/&explain=([^&]*)/', '', $_SERVER['REQUEST_URI'])) . '"><img src="' . $phpbb_root_path . 'adm/images/header_left.jpg" width="200" height="60" alt="phpBB Logo" title="phpBB Logo" border="0"/></a></td><td width="100%" background="' . $phpbb_root_path . 'adm/images/header_bg.jpg" height="60" align="right" nowrap="nowrap"><span class="maintitle">SQL Report</span> </td></tr></table><br clear="all"/><table width="95%" cellspacing="1" cellpadding="4" border="0" align="center"><tr><td height="40" align="center" valign="middle"><b>Page generated in ' . round($totaltime, 4) . " seconds with {$this->num_queries} queries" . (($cache_num_queries) ? " + $cache_num_queries " . (($cache_num_queries == 1) ? 'query' : 'queries') . ' returning data from cache' : '') . '</b></td></tr><tr><td align="center" nowrap="nowrap">Time spent on MSSQL queries: <b>' . round($this->sql_time, 5) . 's</b> | Time spent on PHP: <b>' . round($totaltime - $this->sql_time, 5) . 's</b></td></tr></table><table width="95%" cellspacing="1" cellpadding="4" border="0" align="center"><tr><td>'; + echo '<table width="100%" cellspacing="0" cellpadding="0" border="0"><tr><td><a href="' . htmlspecialchars(preg_replace('/&explain=([^&]*)/', '', $_SERVER['REQUEST_URI'])) . '"><img src="' . $phpbb_root_path . 'adm/images/header_left.jpg" width="200" height="60" alt="phpBB Logo" title="phpBB Logo" border="0"/></a></td><td width="100%" background="' . $phpbb_root_path . 'adm/images/header_bg.jpg" height="60" align="right" nowrap="nowrap"><span class="maintitle">SQL Report</span> </td></tr></table><br clear="all"/><table width="95%" cellspacing="1" cellpadding="4" border="0" align="center"><tr><td height="40" align="center" valign="middle"><b>Page generated in ' . round($totaltime, 4) . " seconds with {$this->num_queries} queries" . (($cache_num_queries) ? " + $cache_num_queries " . (($cache_num_queries == 1) ? 'query' : 'queries') . ' returning data from cache' : '') . '</b></td></tr><tr><td align="center" nowrap="nowrap">Time spent on MySQL queries: <b>' . round($this->sql_time, 5) . 's</b> | Time spent on PHP: <b>' . round($totaltime - $this->sql_time, 5) . 's</b></td></tr></table><table width="95%" cellspacing="1" cellpadding="4" border="0" align="center"><tr><td>'; echo $sql_report; echo '</td></tr></table><br /></body></html>'; exit; @@ -544,58 +514,6 @@ class sql_db $query_hold = $query; $html_hold = ''; - $explain_query = $query; - if (preg_match('/UPDATE ([a-z0-9_]+).*?WHERE(.*)/s', $query, $m)) - { - $explain_query = 'SELECT * FROM ' . $m[1] . ' WHERE ' . $m[2]; - } - elseif (preg_match('/DELETE FROM ([a-z0-9_]+).*?WHERE(.*)/s', $query, $m)) - { - $explain_query = 'SELECT * FROM ' . $m[1] . ' WHERE ' . $m[2]; - } - - if (preg_match('/^SELECT/', $explain_query)) - { - $html_table = FALSE; - - @odbc_exec($this->db_connect_id, 'SET SHOWPLAN_ALL ON'); - - if ($result = $this->_odbc_execute_query($explain_query)) - { - while ($row = $this->sql_fetchrow($result)) - { - if (!$html_table && sizeof($row)) - { - $html_table = TRUE; - $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)) : ' ') . '</th>'; - } - $html_hold .= '</tr>'; - } - $html_hold .= '<tr>'; - - $class = 'row1'; - foreach (array_values($row) as $val) - { - $class = ($class == 'row1') ? 'row2' : 'row1'; - $html_hold .= '<td class="' . $class . '">' . (($val) ? $val : ' ') . '</td>'; - } - $html_hold .= '</tr>'; - } - $this->sql_freeresult($result); - } - - @odbc_exec($this->db_connect_id, 'SET SHOWPLAN_ALL OFF'); - - if ($html_table) - { - $html_hold .= '</table>'; - } - } - $curtime = explode(' ', microtime()); $curtime = $curtime[0] + $curtime[1]; break; @@ -605,6 +523,7 @@ class sql_db $endtime = $endtime[0] + $endtime[1]; $result = $this->_odbc_execute_query($query); + $splittime = explode(' ', microtime()); $splittime = $splittime[0] + $splittime[1]; @@ -619,7 +538,7 @@ class sql_db // Pad the start time to not interfere with page timing $starttime += $time_db; - $this->sql_freeresult($result); + @odbc_free_result($result); $cache_num_queries++; break; @@ -640,7 +559,7 @@ class sql_db else { $error = $this->sql_error(); - $sql_report .= '<b style="color: red">FAILED</b> - MSSQL Error ' . $error['code'] . ': ' . htmlspecialchars($error['message']); + $sql_report .= '<b style="color: red">FAILED</b> - ' . SQL_LAYER . ' Error ' . $error['code'] . ': ' . htmlspecialchars($error['message']); } $sql_report .= '</p>'; |