我的模型如下
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 的新手,整天都坚持使用它。