Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/248.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在CAKEPHP2.x中对自定义分页中的数据进行排序?_Php_Cakephp_Pagination - Fatal编程技术网

如何在CAKEPHP2.x中对自定义分页中的数据进行排序?

如何在CAKEPHP2.x中对自定义分页中的数据进行排序?,php,cakephp,pagination,Php,Cakephp,Pagination,我得到了今天的数据: public function index() { $this->Apertura->recursive = 0; $now = new DateTime(); $options = array('conditions' => array('Apertura.created >= ' => $now->format('Y-m-d 00:00:00'))); $this->set('apertura

我得到了今天的数据:

public function index() {
    $this->Apertura->recursive = 0;
    $now = new DateTime();
    $options = array('conditions' => array('Apertura.created >= ' => $now->format('Y-m-d 00:00:00')));  
    $this->set('aperturas',
        $this->Apertura->find('all', $options),
        $this->Paginator->paginate('Apertura', array('Apertura.created >= ' => $now->format('Y-m-d 00:00:00'))));
}
但当我剪切标题列时,我无法对表进行排序:

        <th><?php echo $this->Paginator->sort('id',"ID"); ?></th>
        <th><?php echo $this->Paginator->sort('Vendedore.nombre',"Vendedor"); ?></th>
        <th><?php echo $this->Paginator->sort('vehiculo_id',"Vehículo"); ?></th>
        <th><?php echo $this->Paginator->sort('observaciones',"Observaciones"); ?></th>
        <th><?php echo $this->Paginator->sort('created',"Hora y fecha"); ?></th>
如果删除条件和自定义分页,则可以对表进行排序。发生了什么事?

是的,解决方案是:

public function index() {
    $this->Apertura->recursive = 0;
    $now = new DateTime();
    $this->Paginator->settings = array(
        'conditions' => array('Apertura.created >= ' => $now->format('Y-m-d 00:00:00')),
        'limit' => 10
    );

    $data = $this->Paginator->paginate('Apertura');

    $this->set('aperturas',$data);
}

错误是。。。?我不能分类这张表对问题的描述很差。请阅读Eeey man,CakePHP2.x中没有错误通知,我在mysql中执行了由Cake的调试工具包自动生成的查询,一切都很完美,我认为错误在自定义分页中,但我不知道为什么。对不起我的英语。n、 n