【问题标题】:Zend Framework ORDER BYZend 框架 ORDER BY
【发布时间】:2012-05-02 21:45:28
【问题描述】:

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

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

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

谢谢

【问题讨论】:

    标签: zend-framework


    【解决方案1】:

    您需要将选择对象传递给 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);
    }
    

    【讨论】:

      猜你喜欢
      • 2020-08-31
      • 1970-01-01
      • 2010-12-14
      • 1970-01-01
      • 2022-01-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多