diff options
author | Andreas Fischer <bantu@phpbb.com> | 2012-05-09 12:55:58 +0200 |
---|---|---|
committer | Andreas Fischer <bantu@phpbb.com> | 2012-05-09 12:55:58 +0200 |
commit | 1a9b30b87118333f0d58eaec3762fc1a579d7b8a (patch) | |
tree | 58ec13e0f9bdf0acdbf0a82220b4e6257506a0b2 /phpBB/includes/db | |
parent | 30579ecb09e2160c450e5d740c36ab052d2ec93d (diff) | |
parent | 12dbcc7f1e13f71b96a5aa31ece4632fb1eb4139 (diff) | |
download | forums-1a9b30b87118333f0d58eaec3762fc1a579d7b8a.tar forums-1a9b30b87118333f0d58eaec3762fc1a579d7b8a.tar.gz forums-1a9b30b87118333f0d58eaec3762fc1a579d7b8a.tar.bz2 forums-1a9b30b87118333f0d58eaec3762fc1a579d7b8a.tar.xz forums-1a9b30b87118333f0d58eaec3762fc1a579d7b8a.zip |
Merge branch 'develop-olympus' into develop
* develop-olympus:
[ticket/10858] Move generic row seeking to DBAL
[ticket/10858] Tests for row seeking with fetchfield()
[ticket/10858] Fix MSSQL Native's row seeking behavior
Conflicts:
tests/dbal/select_test.php
Diffstat (limited to 'phpBB/includes/db')
-rw-r--r-- | phpBB/includes/db/dbal.php | 43 | ||||
-rw-r--r-- | phpBB/includes/db/firebird.php | 43 | ||||
-rw-r--r-- | phpBB/includes/db/mssql_odbc.php | 43 | ||||
-rw-r--r-- | phpBB/includes/db/mssqlnative.php | 18 |
4 files changed, 43 insertions, 104 deletions
diff --git a/phpBB/includes/db/dbal.php b/phpBB/includes/db/dbal.php index 6da854b6e2..db469ed969 100644 --- a/phpBB/includes/db/dbal.php +++ b/phpBB/includes/db/dbal.php @@ -194,6 +194,49 @@ class dbal } /** + * Seek to given row number + * rownum is zero-based + */ + function sql_rowseek($rownum, &$query_id) + { + global $cache; + + if ($query_id === false) + { + $query_id = $this->query_result; + } + + if (isset($cache->sql_rowset[$query_id])) + { + return $cache->sql_rowseek($rownum, $query_id); + } + + if ($query_id === false) + { + return false; + } + + $this->sql_freeresult($query_id); + $query_id = $this->sql_query($this->last_query_text); + + if ($query_id === false) + { + return false; + } + + // We do not fetch the row for rownum == 0 because then the next resultset would be the second row + for ($i = 0; $i < $rownum; $i++) + { + if (!$this->sql_fetchrow($query_id)) + { + return false; + } + } + + return true; + } + + /** * Fetch field * if rownum is false, the current row is used, else it is pointing to the row (zero-based) */ diff --git a/phpBB/includes/db/firebird.php b/phpBB/includes/db/firebird.php index 2ce9e50f46..7709e8fdf5 100644 --- a/phpBB/includes/db/firebird.php +++ b/phpBB/includes/db/firebird.php @@ -359,49 +359,6 @@ class dbal_firebird extends dbal } /** - * Seek to given row number - * rownum is zero-based - */ - function sql_rowseek($rownum, &$query_id) - { - global $cache; - - if ($query_id === false) - { - $query_id = $this->query_result; - } - - if (isset($cache->sql_rowset[$query_id])) - { - return $cache->sql_rowseek($rownum, $query_id); - } - - if ($query_id === false) - { - return; - } - - $this->sql_freeresult($query_id); - $query_id = $this->sql_query($this->last_query_text); - - if ($query_id === false) - { - return false; - } - - // We do not fetch the row for rownum == 0 because then the next resultset would be the second row - for ($i = 0; $i < $rownum; $i++) - { - if (!$this->sql_fetchrow($query_id)) - { - return false; - } - } - - return true; - } - - /** * Get last inserted id after insert statement */ function sql_nextid() diff --git a/phpBB/includes/db/mssql_odbc.php b/phpBB/includes/db/mssql_odbc.php index 909e43808f..7ead00cece 100644 --- a/phpBB/includes/db/mssql_odbc.php +++ b/phpBB/includes/db/mssql_odbc.php @@ -255,49 +255,6 @@ class dbal_mssql_odbc extends dbal } /** - * Seek to given row number - * rownum is zero-based - */ - function sql_rowseek($rownum, &$query_id) - { - global $cache; - - if ($query_id === false) - { - $query_id = $this->query_result; - } - - if (isset($cache->sql_rowset[$query_id])) - { - return $cache->sql_rowseek($rownum, $query_id); - } - - if ($query_id === false) - { - return false; - } - - $this->sql_freeresult($query_id); - $query_id = $this->sql_query($this->last_query_text); - - if ($query_id === false) - { - return false; - } - - // We do not fetch the row for rownum == 0 because then the next resultset would be the second row - for ($i = 0; $i < $rownum; $i++) - { - if (!$this->sql_fetchrow($query_id)) - { - return false; - } - } - - return true; - } - - /** * Get last inserted id after insert statement */ function sql_nextid() diff --git a/phpBB/includes/db/mssqlnative.php b/phpBB/includes/db/mssqlnative.php index 4abef6fc3c..8aac032135 100644 --- a/phpBB/includes/db/mssqlnative.php +++ b/phpBB/includes/db/mssqlnative.php @@ -439,24 +439,6 @@ class dbal_mssqlnative extends dbal } /** - * Seek to given row number - * rownum is zero-based - */ - function sql_rowseek($rownum, &$query_id) - { - global $cache; - - if (isset($cache->sql_rowset[$query_id])) - { - return $cache->sql_rowseek($rownum, $query_id); - } - - $seek = new result_mssqlnative($query_id); - $row = $seek->seek($rownum); - return ($row = $seek->fetch()) ? $row : false; - } - - /** * Get last inserted id after insert statement */ function sql_nextid() |