1
你好我有这样的用户模型的关系。CakePHP分页计数查询不起作用
的usermodel
public $hasOne = [
'Userdetail' => [
'className' => 'Userdetail',
'foreignKey' => 'user_id'
],
'Application' => [
'className' => 'Application',
'foreignKey' => 'user_id'
],
];
我在下面MyConroller像添加额外的HasOne关系:
控制器
$this->User->bindModel([
'hasOne' => [
'Events' => [
'className' => 'Events',
'foreignKey' => 'user_id',
'dependent' => true,
]
]
]);
我创建一个用户模型像下面分页:
分页
$this->paginate = [
'conditions' => [
$this->conditions,
'Events.id !=' => null
],
'order' => 'User.id DESC'
];
我不希望记录,其事件ID为空,所以我把这个分页条件。比我低于错误。
Unknown column 'Events.id' in 'where clause'
事件的模型不反映在Count分页查询中。
请帮我解决这个问题。
在此先感谢您的帮助。
'$这 - >用户 - > bindModel([ \t 'hasOne'=> [ \t \t '事件'=> [ \t \t \t '的className'=> '事件', \t \t \t 'FOREIGNKEY'=> 'USER_ID', \t \t \t '依赖'=>真, \t \t], \t \t '条件'=> [ '!Events.id ='=>空, \t \t] \t] ]);'和'从分页condition' –
删除它不,它是CakePHP的2.6 –
我试试这个@ Anant,但它不起作用 –