aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/db/mssql.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes/db/mssql.php')
-rw-r--r--phpBB/includes/db/mssql.php11
1 files changed, 9 insertions, 2 deletions
diff --git a/phpBB/includes/db/mssql.php b/phpBB/includes/db/mssql.php
index 5d6095e502..8e0ca2377c 100644
--- a/phpBB/includes/db/mssql.php
+++ b/phpBB/includes/db/mssql.php
@@ -105,10 +105,10 @@ class dbal_mssql extends dbal
}
$this->query_result = ($cache_ttl && method_exists($cache, 'sql_load')) ? $cache->sql_load($query) : false;
+ $this->sql_add_num_queries($this->query_result);
if (!$this->query_result)
{
- $this->num_queries++;
if (($this->query_result = @mssql_query($query, $this->db_connect_id)) === false)
{
$this->sql_error($query);
@@ -160,7 +160,14 @@ class dbal_mssql extends dbal
$row_offset = ($total) ? $offset : '';
$num_rows = ($total) ? $total : $offset;
- $query = 'SELECT TOP ' . ($row_offset + $num_rows) . ' ' . substr($query, 6);
+ 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);
+ }
return $this->sql_query($query, $cache_ttl);
}