【问题标题】:cakephp paginate order ignoredcakephp分页顺序被忽略
【发布时间】:2013-11-21 23:39:14
【问题描述】:

我在订购分页请求时遇到问题。 我正在使用一个带有两个字段的 MySQL 视图表:id、date_ordered,这是主表中两个日期字段中最早的一个。 我在另一个应用程序上使用了完全相同的技术,一切顺利。我不明白为什么生成的 SQL 没有显示任何 ORDER BY 子句。

控制器

public function admin($id=null) { 
    $today = date("Y-m-d");
    $this->DA->recursive = 0;
    $this->paginate = array(
        'conditions' => array(
            'DAO.date_ordered LIKE '=>"$today%",
        ),
        'joins' => array(
            array(
                'table' => 'DA_ordered', 
                'alias' => 'DAO', 
                'type' => 'INNER', 
                'foreignKey' => false, 
                'conditions'=> '`DAO`.`id` = `DA`.`id`'
            )
        ), 
        'order' => array('DAO.date_ordered' => 'desc'),
        'limit' => 1000
    );

    $this->set('req', $this->paginate());
}

我的网址中没有订单字段,具有相同结构的视图表完全相同的代码在其他应用程序中运行良好...

【问题讨论】:

    标签: mysql cakephp-2.3


    【解决方案1】:

    解决方法:

    'order' => 'DAO.date_ordered DESC'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-09-13
      • 1970-01-01
      • 2020-02-18
      • 2017-11-30
      • 2011-06-16
      • 2013-08-24
      相关资源
      最近更新 更多