找到前两篇文章

Fea*_*236 -2 cakephp

我需要找到前两篇文章.可以说,我从数据库中得到了一篇文章:

    Array
(
    [0] => Array
        (
            [Pressroom] => Array
                (
                    [id] => 44
                    [created] => 2013-04-17 07:38:20
                    [date] => 2013-04-17
                    [modified] => 2013-04-23 07:58:25
                )

        )
Run Code Online (Sandbox Code Playgroud)

我还需要找到两个优先记录(让我们说id 43和42).任何sugestions?我完全不知道.

我试图在我的模型中使用此代码:

$this->find('all',
            array(
                'order' => array(
                    'Pressroom.date' => 'DESC',
                    'Pressroom.created' => 'DESC'
                ),
                'limit' => 2,
                'conditions' => array('Pressroom.date <' => $data['Pressroom']['date'])));
Run Code Online (Sandbox Code Playgroud)

但它找到两个id为1和2的记录,而不是43和42

tob*_*obi 5

你的问题有点不清楚,但是会有这样的工作吗?

$articles = $this->Pressroom->find('all', array(
    'conditions' => array('id <=' => 44),
    'order' => array('id' => 'desc'),
    'limit' => 3
));
Run Code Online (Sandbox Code Playgroud)