summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2013-03-04 11:50:06 +0100
committerAleksander Machniak <alec@alec.pl>2013-03-04 11:50:06 +0100
commit879b2331e11ff90030c514aa5eb1459004ff14c3 (patch)
treee7bd89b8b05765f33933dbc920a7409514cf0fb1
parent8c93c29d04e5ef3cc81a86ac03708a758071b73c (diff)
Generate simpler query for MSSQL when offset in limit clause is not set
-rw-r--r--program/lib/Roundcube/rcube_db_mssql.php4
1 files changed, 4 insertions, 0 deletions
diff --git a/program/lib/Roundcube/rcube_db_mssql.php b/program/lib/Roundcube/rcube_db_mssql.php
index 84fe22bbc..a1ce80a87 100644
--- a/program/lib/Roundcube/rcube_db_mssql.php
+++ b/program/lib/Roundcube/rcube_db_mssql.php
@@ -110,6 +110,10 @@ class rcube_db_mssql extends rcube_db
$query = preg_replace('/^SELECT\s/i', 'SELECT TOP ' . ($limit + $offset) . ' ', $query);
+ if (!$offset) {
+ return $query;
+ }
+
$query = 'SELECT * FROM (SELECT TOP ' . $limit . ' * FROM (' . $query . ') AS inner_tbl';
if ($orderby !== false) {
$query .= ' ORDER BY ' . $order . ' ';