Zend Framework ORDER BY

Rex*_*x89 2 zend-framework

我有一个项目列表,我想按字母顺序排序,继承我的代码:

public function indexAction()
{
    $this->authoriseUser();
    $this->view->assign('title', 'Clubs');
    $this->view->headTitle($this->view->title, 'PREPEND');
    $clubs = new Application_Model_DbTable_Clubs();
    $this->view->clubs = $clubs->fetchAll();
    $select = $clubs->select();
    $select->order('club_name ASC');
}
Run Code Online (Sandbox Code Playgroud)

怎么了?因为它不起作用..

谢谢

Rat*_*tzo 7

您需要将select对象传递给fetchAll方法

public function indexAction()
{
    $this->authoriseUser();
    $this->view->assign('title', 'Clubs');
    $this->view->headTitle($this->view->title, 'PREPEND');
    $clubs = new Application_Model_DbTable_Clubs();
    $select = $clubs->select()
        ->order('club_name ASC');
    $this->view->clubs = $clubs->fetchAll($select);
}
Run Code Online (Sandbox Code Playgroud)