1
0
mirror of synced 2024-12-14 07:06:04 +03:00
This commit is contained in:
zYne 2006-12-13 21:23:33 +00:00
parent e89bfc8d40
commit bde8d33fc3

View File

@ -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 {
// 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;
} }