2

我有一个我想按字母顺序订购的项目列表,这是我的代码:

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

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

谢谢

4

1 回答 1

7

您需要将选择对象传递给 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);
}
于 2012-05-02T21:51:01.513 回答