Zend Framework ORDER BY

时间:2012-05-02 21:45:29

标签: 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');
}

什么错了?因为它不起作用..

由于

1 个答案:

答案 0 :(得分:6)

您需要将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);
}