Cakephp 2.4限制在使用下限和上限时不起作用

时间:2014-04-07 09:09:03

标签: cakephp-2.0 cakephp-2.3

下面的cakephp查询返回一个空的数组结果,但是如果我只使用$max_results就可以了。 我想从两个限制(0,10)中搜索记录。

这不起作用。

$from = 0;
$max_results = 10;
$this->Model->find('all',array(
      'conditions'=>$condition,
      "order"=>'Model.id DESC',
      'limit'=>"$from,$max_results"
));

1 个答案:

答案 0 :(得分:1)

您需要使用偏移选项 -

   $from = 0;
    $max_results = 10;
    $this->Model->find('all',array(
          'conditions'=>$condition,
          "order"=>'Model.id DESC',
          'limit'=>"$max_results",
          'offset' => "$from"
    ));