Issues

ZF-10947: Zend_Paginator_Adapter_DbSelect->getCountSelect() - the count query produced by this method fails if the original Zend_Db_Select contains "order by" (and using Zend_Db_Adapter_Sqlsrv)

Issue Type: Bug Created: 2011-01-14T03:31:04.000+0000 Last Updated: 2011-02-18T07:41:26.000+0000 Status: Resolved Fix version(s): - 1.11.4 (03/Mar/11)

Reporter: Ian Smith (smivz) Assignee: Ramon Henrique Ornelas (ramon) Tags: - Zend_Paginator

Related issues: Attachments:

Description

Zend_Paginator_Adapter_DbSelect->getCountSelect() - the count query produced by this method fails if the original Zend_Db_Select contains "order by" (and using Zend_Db_Adapter_Sqlsrv).

The sql generated by the Zend_Db_Select object is ok:

$select = $db->select() ->from(array('icp' => 'icn_ptnt'), array('Surname', 'Firstname')) ->join(array('apm' => 'abx_patient_medications'), 'icp.Patient_No = apm.patient_id', array()) ->group(array('Surname', 'Firstname')) ->order(array('Surname'));

SELECT "icp"."Surname", "icp"."Firstname" FROM "icn_ptnt" AS "icp" INNER JOIN "abx_patient_medications" AS "apm" ON icp.Patient_No = apm.patient_id GROUP BY "Surname", "Firstname" ORDER BY "Surname" ASC

However, an error is encoutered once this is passed to Zend_Paginator

$view->paginator = Zend_Paginator::factory($select); $view->paginator->setCurrentPageNumber((isset($_GET['page'])) ? $_GET['page'] : 1); $view->paginator->setItemCountPerPage(100);

SELECT COUNT(1) AS "zend_paginator_row_count" FROM (SELECT "icp"."Surname", "icp"."Firstname" FROM "icn_ptnt" AS "icp" INNER JOIN "abx_patient_medications" AS "apm" ON icp.Patient_No = apm.patient_id GROUP BY "Surname", "Firstname" ORDER BY "Surname" ASC) AS "t"

Msg 1033, Level 15, State 1, Line 3 The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP or FOR XML is also specified.

Comments

Posted by Ramon Henrique Ornelas (ramon) on 2011-02-18T07:41:26.000+0000

Fixed in trunk r23724 merged to branch release 1.11 r23725.

Have you found an issue?

See the Overview section for more details.

Copyright

© 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.

Contacts