“Order By” for Zend Db findDependentRowset()

This is another one of those note-to-self style posts.

Design decisions on Zend Db’s “Zend_Db_Table_Row_Abstract” class prevent the inclusion of an ‘order by’ clause directly in the (incredibly useful) “findDependentRowset” function.

But you can pass in the order by clause indirectly through a select statement as follows.

What you want would be something like:

$depRows = $row->findDependentRowset('DEP_TABLE_NAME', /*order by=*/'SORT_ORDER ASC');

and you get this by doing the following:

$depTable = new DEP_TABLE_NAME();
$depRows = $row->findDependentRowset($depTable, null, $depTable->select()->order('SORT_ORDER ASC'));


  1. #1 by William M Buck on November 14, 2014 - 12:56 pm

    Thank you for this tip. I have a little website I’ve built for a Brazilian doctor keeping track of some patient information. I needed just this facility, and your article saved me having to try to figure it out myself.

(will not be published)