2015-10-12 18 views
0

我得到今天的数据:如何对CAKEPHP2.x中的自定义分页数据进行排序?

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> 

我可以整理桌子。发生什么事?

+0

和错误是...? “我无法对表格进行排序”对问题的描述很差。请阅读http://university.utest.com/writing-quality-bug-reports-and-utest-etiquette/ – burzum

+0

Eeeey man,CakePHP2.x中没有错误通知,我执行了由调试工具自动生成的查询在MySQL中的Cake和所有的都是完美的,我认为错误是在自定义分页中,但我不知道为什么。对不起我的英语不好。 N,N- –

回答

0

是,该解决方案是:

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); 
} 
相关问题