CakePHP 使用与 HABTM 链接的另一个表上的条件对结果进行分页
我已经进行了一些搜索,但找不到任何与我的场景足够相关/有效的内容。我有:
Jobs <--> HABTM (Users_jobs table) <--> Users
我想从我的 Job
控制器执行 paginate()
,并在 User.id
上设置一个条件,因为我确实需要从当前用户获取所有作业并对其进行分页。
如果您确实提供了另一个主题/网站的链接,请提供解释以及如何将其应用到我的案例中。
干杯,
尼古拉斯.
I've done some searching but I can't find anything relevant enough/working for my scenario. I've got:
Jobs <--> HABTM (Users_jobs table) <--> Users
I would like to do a paginate()
from my Job
controller with a condition on the User.id
, as I do need to fetch -and paginate- all the jobs from the current user.
If you do provide a link to another topic/site, please provide an explanation with it and how you would apply it to my case.
Cheers,
Nicolas.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
确保您的 HABTM 关联设置正确(
cake Baker
需要jobs_users
的联接表,而不是users_jobs
(请参阅:Cakephp-HABTM) 如果是,请将下面示例中对 JobsUser 的引用更改为 UsersJob 以匹配你所描述的布局。Make sure your HABTM associations are setup correctly (
cake bake
would expect a join table ofjobs_users
rather thanusers_jobs
(see: Cakephp-HABTM) If they are, change the references to JobsUser in the example below to UsersJob to match the layout you described.