0

我正在使用 cakePHP 1.26。我正在尝试按 DESC 顺序按日期对数据进行排序,但没有运气。

 $this->set('posts', $this->Post->findAllByZero('0', array('order'=>array('Post.createdate DESC'))));

如上所示,我无法弄清楚代码中有什么问题。请问你能帮帮我吗?

编辑原因:

我已经更改了代码,它能够按 DESC 顺序按日期对数据进行排序,
但我不确定是否有最好的方法:

 $this->set('posts', $this->Site1->find('all', array('conditions'=>array('Post.zero'=>'0'), 'order'=>array('Post.created DESC'))));
4

1 回答 1

2

您不能在findBy<fieldname>()findAllBy<fieldname>()方法中指定顺序或任何其他选项,因为它们只接受一个参数,即您要查找的值。恐怕您将不得不改用该find()方法。

于 2010-07-06T18:49:56.200 回答