Zend Framework Magic Method ORDER子句

时间:2010-12-29 18:31:36

标签: php zend-framework

是否可以在魔术方法db结果中添加ORDER BY子句。来自文档:

    $accountsTable = new Accounts();

    $accountsRowset = $accountsTable->find(1234);

    $user1234 = $accountsRowset->current();

    // Use the default reference rule

    // is it possible to add an order to the related tables results?
    $bugsReportedBy = $user1234->findBugs();

    // Specify the reference rule

    $bugsAssignedTo = $user1234->findBugsByEngineer();

1 个答案:

答案 0 :(得分:1)

有点试错,我可以添加ORDER BY子句。您可以传入Zend_Db_Select

的实例
$bugsTable = new Bugs() //extends Zend_Db_Table_Abstract;
$bugsSelect = $bugsTable->select(); 
$bugsSelect->order('name ASC');    
$bugsReportedBy = $user1234->findBugs($bugsSelect);