0

我的模型如下

class SentSms extends AppModel {
var $name = "Sentsms";

var $hasMany =  array(
                    'SentSms1' => array(
                            'className' => 'SentSms',
                            'order'                => 'SentSms1.sql_id DESC',
                                'foreignKey'   => 'parent_key'));
var $belongsTo =  array(
                        'SentSms2' => array(
                                'className' => 'SentSms',
                                'order'                => 'SentSms2.sql_id DESC',
                                'foreignKey'   => 'parent_key'));
}

控制器代码如下:

$this->paginate = array('conditions' => array('service' => $this->Session->read('Auth.User.username'), 'momt' => 'MT'),
                                        'limit' => 25,
                                        'recursive' => '1',
                                        'order' => array('sql_id desc')
    );
    $report = $this->paginate('SentSms');

这里正在执行简单的选择查询。我是 CakePhp 的新手,整天都坚持使用它。

4

1 回答 1

0

递归是数字属性,你应该这样改变你的代码:

$this->paginate = array('conditions' => array('service' => $this->Session->read('Auth.User.username'), 'momt' => 'MT'),
                                        'limit' => 25,
                                        'recursive' => 1,   //change '1' to 1
                                        'order' => array('sql_id desc')
    );
于 2013-07-05T06:19:02.067 回答