Commit bde8d33f authored by zYne's avatar zYne

fixes #251

parent e89bfc8d
...@@ -116,13 +116,13 @@ class Doctrine_Connection_Mssql extends Doctrine_Connection { ...@@ -116,13 +116,13 @@ class Doctrine_Connection_Mssql extends Doctrine_Connection {
// is there an offset? // is there an offset?
if (! $offset) { if (! $offset) {
// no offset, it's a simple TOP count // no offset, it's a simple TOP count
return $select . ' TOP ' . $count . substr($query, $length); return $select . ' TOP ' . $limit . substr($query, $length);
} }
// the total of the count **and** the offset, combined. // the total of the count **and** the offset, combined.
// this will be used in the "internal" portion of the // this will be used in the "internal" portion of the
// hacked-up statement. // hacked-up statement.
$total = $count + $offset; $total = $limit + $offset;
// build the "real" order for the external portion. // build the "real" order for the external portion.
$order = implode(',', $parts['order']); $order = implode(',', $parts['order']);
...@@ -135,13 +135,13 @@ class Doctrine_Connection_Mssql extends Doctrine_Connection { ...@@ -135,13 +135,13 @@ class Doctrine_Connection_Mssql extends Doctrine_Connection {
// create a main statement that replaces the SELECT // create a main statement that replaces the SELECT
// with a SELECT TOP // with a SELECT TOP
$main = "\n$select TOP $total" . substr($query, $length) . "\n"; $main = $select . ' TOP ' . $total . substr($query, $length);
// build the hacked-up statement. // build the hacked-up statement.
// do we really need the "as" aliases here? // do we really need the "as" aliases here?
$query = "SELECT * FROM (" $query = 'SELECT * FROM ('
. "SELECT TOP $count * FROM ($main) AS select_limit_rev ORDER BY $reverse" . 'SELECT TOP ' . $count . ' * FROM (' . $main . ') AS select_limit_rev ORDER BY '. $reverse
. ") AS select_limit ORDER BY $order"; . ') AS select_limit ORDER BY ' . $order;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment