aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/db/mssql_odbc.php
diff options
context:
space:
mode:
authorMeik Sievertsen <acydburn@phpbb.com>2006-09-23 11:10:37 +0000
committerMeik Sievertsen <acydburn@phpbb.com>2006-09-23 11:10:37 +0000
commit6d08ef7b3ab9e481cc56b94865bb07ade34a80ef (patch)
tree8cfe68ddc26ab3776a746ea40c99621076d71c33 /phpBB/includes/db/mssql_odbc.php
parent7542fabaa708677a015ab968724f5b337105702b (diff)
downloadforums-6d08ef7b3ab9e481cc56b94865bb07ade34a80ef.tar
forums-6d08ef7b3ab9e481cc56b94865bb07ade34a80ef.tar.gz
forums-6d08ef7b3ab9e481cc56b94865bb07ade34a80ef.tar.bz2
forums-6d08ef7b3ab9e481cc56b94865bb07ade34a80ef.tar.xz
forums-6d08ef7b3ab9e481cc56b94865bb07ade34a80ef.zip
made sql_rowseek consistent with the dbal methods as well as fixing sql_query_limit for mssql, especially if sql_query_limit($sql, 0, 0) is given...
git-svn-id: file:///svn/phpbb/trunk@6389 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/db/mssql_odbc.php')
-rw-r--r--phpBB/includes/db/mssql_odbc.php37
1 files changed, 15 insertions, 22 deletions
diff --git a/phpBB/includes/db/mssql_odbc.php b/phpBB/includes/db/mssql_odbc.php
index 54655c389a..09437a1780 100644
--- a/phpBB/includes/db/mssql_odbc.php
+++ b/phpBB/includes/db/mssql_odbc.php
@@ -168,33 +168,26 @@ class dbal_mssql_odbc extends dbal
{
$this->query_result = false;
- // if $total is set to 0 we do not want to limit the number of rows
- if ($total == 0)
+ // Since TOP is only returning a set number of rows we won't need it if total is set to 0 (return all rows)
+ if ($total)
{
- $total = -1;
- }
-
- $row_offset = ($total) ? $offset : 0;
- $num_rows = ($total) ? $total : $offset;
-
- if (strpos($query, 'SELECT DISTINCT') === 0)
- {
- $query = 'SELECT DISTINCT TOP ' . ($row_offset + $num_rows) . ' ' . substr($query, 15);
- }
- else
- {
- $query = 'SELECT TOP ' . ($row_offset + $num_rows) . ' ' . substr($query, 6);
+ // We need to grab the total number of rows + the offset number of rows to get the correct result
+ if (strpos($query, 'SELECT DISTINCT') === 0)
+ {
+ $query = 'SELECT DISTINCT TOP ' . ($total + $offset) . ' ' . substr($query, 15);
+ }
+ else
+ {
+ $query = 'SELECT TOP ' . ($total + $offset) . ' ' . substr($query, 6);
+ }
}
$result = $this->sql_query($query, $cache_ttl);
- // Seek by $row_offset rows
- if ($row_offset)
+ // Seek by $offset rows
+ if ($offset)
{
- for ($i = 0; $i < $row_offset; $i++)
- {
- $this->sql_fetchrow($result);
- }
+ $this->sql_rowseek($offset, $result);
}
return $result;
@@ -301,7 +294,7 @@ class dbal_mssql_odbc extends dbal
if (isset($cache->sql_rowset[$query_id]))
{
- return $cache->sql_rowseek($query_id, $rownum);
+ return $cache->sql_rowseek($rownum, $query_id);
}
$this->sql_freeresult($query_id);