BUGFIX Fixing order by fields for SS 3.0 in MSSQLDatabase::sqlQueryToString()

This commit is contained in:
Sean Harvey 2012-04-27 17:25:50 +12:00
parent c7ae517c99
commit cb01716d39

View File

@ -1227,7 +1227,8 @@ class MSSQLDatabase extends SS_Database {
// If there's a limit and an offset, then we need to do a subselect
} else if($limit && $offset) {
if($sqlQuery->orderby) {
$rowNumber = "ROW_NUMBER() OVER (ORDER BY $sqlQuery->orderby) AS Number";
$orderByFields = (method_exists($sqlQuery, 'prepareOrderBy')) ? $sqlQuery->prepareOrderBy() : $sqlQuery->orderby;
$rowNumber = "ROW_NUMBER() OVER (ORDER BY $orderByFields) AS Number";
} else {
$firstCol = reset($sqlQuery->select);
$rowNumber = "ROW_NUMBER() OVER (ORDER BY $firstCol) AS Number";