Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Update libraries/joomla/database/driver/sqlsrv.php #1818

Merged
merged 1 commit into from

3 participants

@MDunkleSr

Add ' ORDER BY RowNumber' to limit(). Without ORDER BY, limit function returns results that do not honor the original ORDER BY specified in the query.

@MDunkleSr MDunkleSr Update libraries/joomla/database/driver/sqlsrv.php
Add ' ORDER BY RowNumber' to limit(). Without ORDER BY, limit function returns results that do not honor the original ORDER BY specified in the query.
5b983e1
@dongilbert
Collaborator

If someone with sqlsrv access can confirm this, I think it's good to merge. @mbabker? (Sorry, always picking on you.)

@MDunkleSr

Not that it changes the need for independent confirmation, but I do have it running w/ desired results in both a test & production environment. LMK if I need to clarify anything.

Appreciate you taking a look at this & considering it for merge!

Thanks,

Mike

@dongilbert
Collaborator

That's good to know. I trust testing and production usage more than one off testing, TBH. I just don't have access to sqlsrv (that I know of) to test it myself.

@mbabker
Owner

I'll be firing up my Windows & SQL Server environment this weekend for some CMS work, but I'll add this to my to-do list as well.

@dongilbert dongilbert merged commit 7172fb5 into from
@MDunkleSr MDunkleSr deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 31, 2013
  1. @MDunkleSr

    Update libraries/joomla/database/driver/sqlsrv.php

    MDunkleSr authored
    Add ' ORDER BY RowNumber' to limit(). Without ORDER BY, limit function returns results that do not honor the original ORDER BY specified in the query.
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  libraries/joomla/database/driver/sqlsrv.php
View
2  libraries/joomla/database/driver/sqlsrv.php
@@ -985,7 +985,7 @@ protected function limit($sql, $limit, $offset)
$rowNumberText = ',ROW_NUMBER() OVER (' . $orderBy . ') AS RowNumber FROM ';
$sql = preg_replace('/\\s+FROM/', '\\1 ' . $rowNumberText . ' ', $sql, 1);
- $sql = 'SELECT TOP ' . $this->limit . ' * FROM (' . $sql . ') _myResults WHERE RowNumber > ' . $this->offset;
+ $sql = 'SELECT TOP ' . $this->limit . ' * FROM (' . $sql . ') _myResults WHERE RowNumber > ' . $this->offset . ' ORDER BY RowNumber';
return $sql;
}
Something went wrong with that request. Please try again.