显示特定用户的 habtm 关系时出现问题
我有 3 个表(Accessories、User、Accesories_Users)...在 Accessories_Controller 我只是想从登录的用户那里获取附件,所以我设置 recursive=1 然后执行 find...
问题是,如果我do
$this->Accessory->find("All", array('conditions'=>array('AccessoriesUser.user_id'=>$this->Auth->User('id'), 'AccessoriesUser.Accesory_id'=>'Accessory.id')));
有一个错误,因为它找不到 Accessory_id 字段...我可以使用自定义查询来管理它,但这不是想法...然后即使我执行自定义查询解决方案,我也无法对查询返回的数组进行分页.. 预先感谢
您能给我的任何帮助...
I got 3 tables (Accessories, User, Accesories_Users)... At Accessories_Controller im trying just to get the accessories from the user logged in, so i set the recursive=1 and then execute the find...
The problem is, if i do
$this->Accessory->find("All", array('conditions'=>array('AccessoriesUser.user_id'=>$this->Auth->User('id'), 'AccessoriesUser.Accesory_id'=>'Accessory.id')));
theres an error cus it doesnt find Accessory_id field.... I could manage this using a custom query but is not the idea... And then even if i do the custom query solution i cannot paginate the array that the query return...
Thanks in advance for any help you can give me...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需使用 var
$paginate = array('conditions'=>array())
对于 habtm 关系
$this->model->bindModel('hasOne'=>aaray('otherModel'));
just use var
$paginate = array('conditions'=>array())
and for habtm relations
$this->model->bindModel('hasOne'=>aaray('otherModel'));