在 CakePHP 中运行与控制器无关的查询
我有一个带有模型作业的作业控制器。
当我点击 /jobs (作业控制器的索引功能)时,我需要在另外 2 个表(未加入作业)上运行查询,以查找要在实际显示索引之前手动插入到作业中的值。
我已经尝试了几件事,但似乎无法在这方面取得任何进展。
谁能帮我解决这个问题吗?
1) 从客户和包裹的联接中选择字段(复杂条件) 2)迭代结果并在作业中插入/更新值 3) 显示职位
预先感谢您。
马尼坎丹
I have a Controller for Jobs with a model Job.
When I hit /jobs (the index function of Job Controller), I need to run a query on 2 other tables (not joined to Job) to find values to manually insert into jobs before actually displaying the index.
I have tried several things but can't seem to make any progress on this.
Can anyone help me with this?
1) select fields from a join on customers and packages (complex conditions)
2) iterate through results and insert/update values in job
3) display jobs
Thank you in advance.
Manikandan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以通过多种方式加载不相关的模型,但这对于控制器来说可能是最好的:
替代方案包括:
或:
You can load non-related models in a number of ways, but this is probably the best one for controllers:
Alternatives include:
or:
如果放在 AppController 中的 beforeFilter 下,这也可能有效:
this may work as well if placed under beforeFilter in AppController: