From 09081e410fc015c71dbd460aeafade42d7070b78 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Tue, 1 Aug 2006 16:14:14 +0000 Subject: - acm_file uses an index pointer to the current row instead of shifting the result array now [Bug #2451] - all dbals adjusted to use the cache in sql_fetchfield, sql_rowseek, sql_numrows and sql_freeresult [Bug #2451] - use include_once for dbal.php to at least theoretically allow connections to multiple databases at once - added a space to an SQL query [Bug #3506] - detailed information on adding friends/foes [Bugs #2509, #2499] - e modifier stands for evil, so I removed it ;-) - corrected progress_bar image filename in imageset.cfg [Bug #3374] git-svn-id: file:///svn/phpbb/trunk@6225 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/db/mysql.php | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/db/mysql.php') diff --git a/phpBB/includes/db/mysql.php b/phpBB/includes/db/mysql.php index 60e56e2964..7e363721a9 100644 --- a/phpBB/includes/db/mysql.php +++ b/phpBB/includes/db/mysql.php @@ -22,7 +22,7 @@ if (!defined('SQL_LAYER')) { define('SQL_LAYER', 'mysql'); - include($phpbb_root_path . 'includes/db/dbal.' . $phpEx); + include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx); /** * MySQL Database Abstraction Layer @@ -89,6 +89,12 @@ class dbal_mysql extends dbal /** * Base query method + * + * @param string $query Contains the SQL query which shall be executed + * @param int $cache_ttl Either 0 to avoid caching or the time in seconds which the result shall be kept in cache + * @return mixed When casted to bool the returned value returns true on success and false on failure + * + * @access public */ function sql_query($query = '', $cache_ttl = 0) { @@ -171,11 +177,18 @@ class dbal_mysql extends dbal */ function sql_numrows($query_id = false) { + global $cache; + if (!$query_id) { $query_id = $this->query_result; } + if (isset($cache->sql_rowset[$query_id])) + { + return $cache->sql_numrows($query_id); + } + return ($query_id) ? @mysql_num_rows($query_id) : false; } @@ -213,6 +226,8 @@ class dbal_mysql extends dbal */ function sql_fetchfield($field, $rownum = false, $query_id = false) { + global $cache; + if (!$query_id) { $query_id = $this->query_result; @@ -222,11 +237,22 @@ class dbal_mysql extends dbal { if ($rownum === false) { + if (isset($cache->sql_rowset[$query_id])) + { + return $cache->sql_fetchfield($query_id, $field); + } + $row = $this->sql_fetchrow($query_id); return isset($row[$field]) ? $row[$field] : false; } else { + if (isset($cache->sql_rowset[$query_id])) + { + $cache->sql_rowseek($query_id, $rownum); + return $cache->sql_fetchfield($query_id, $field); + } + return @mysql_result($query_id, $rownum, $field); } } @@ -240,11 +266,18 @@ class dbal_mysql extends dbal */ function sql_rowseek($rownum, $query_id = false) { + global $cache; + if (!$query_id) { $query_id = $this->query_result; } + if (isset($cache->sql_rowset[$query_id])) + { + return $cache->sql_rowseek($query_id, $rownum); + } + return ($query_id) ? @mysql_data_seek($query_id, $rownum) : false; } @@ -261,11 +294,18 @@ class dbal_mysql extends dbal */ function sql_freeresult($query_id = false) { + global $cache; + if (!$query_id) { $query_id = $this->query_result; } + if (isset($cache->sql_rowset[$query_id])) + { + return $cache->sql_freeresult($query_id); + } + if (isset($this->open_queries[(int) $query_id])) { unset($this->open_queries[(int) $query_id]); -- cgit v1.2.1