aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/db/mssql.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.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.php')
-rw-r--r--phpBB/includes/db/mssql.php34
1 files changed, 15 insertions, 19 deletions
diff --git a/phpBB/includes/db/mssql.php b/phpBB/includes/db/mssql.php
index 52f442f4fa..96716a8814 100644
--- a/phpBB/includes/db/mssql.php
+++ b/phpBB/includes/db/mssql.php
@@ -172,30 +172,26 @@ class dbal_mssql 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 : '';
- $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)
{
- $this->sql_rowseek($result, $row_offset);
+ $this->sql_rowseek($offset, $result);
}
return $result;
@@ -313,7 +309,7 @@ class dbal_mssql extends dbal
if (isset($cache->sql_rowset[$query_id]))
{
- return $cache->sql_rowseek($query_id, $rownum);
+ return $cache->sql_rowseek($rownum, $query_id);
}
return ($query_id) ? @mssql_data_seek($query_id, $rownum) : false;