ZF-2417: Limit with Ordering broken

Issue Type: Bug Created: 2008-01-11T08:01:29.000+0000 Last Updated: 2008-03-21T16:25:28.000+0000 Status: Resolved Fix version(s): - 1.5.0 (17/Mar/08)

Reporter: Thomas Weidner (thomas) Assignee: Thomas Weidner (thomas) Tags: - Zend_Db_Select

Related issues: Attachments:


A query which has a column named 'description' and is ordered by it 'description DESC' will be broken if limited.

The query is:

<pre class="highlight">
$columns = array('name', 'description');
$order = 'description DESC';
$select = new Zend_Db_Select($database);
$select->from('usertable', $columns);
$select->limitPage(1, 10);


Then I get an error... Looking into the created select statement I get:

<pre class="highlight">
SELECT * FROM (SELECT TOP 10 * FROM (SELECT TOP 10 "description", "name" 
>FROM mytable ORDER BY "description" DESC ) AS inner_tbl ORDER BY "ription" 
ASC ) AS outer_tbl ORDER BY "ription" desc

This behaviour can be seen within MSSQL where no native limit exists. Possibly same problem when using any column name where "asc" is included.


Posted by Thomas Weidner (thomas) on 2008-01-11T17:25:21.000+0000

Fixed within SVN-7399

Have you found an issue?

See the Overview section for more details.


© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.