CakePHP 和 Containable
首先我要说的是,我已经尝试尽可能多地阅读 CakePHP 书籍来了解这个特定主题,但无论出于何种原因,我就是无法弄清楚这一点。
我有几个模型:
人
- 每个人可以有很多工作
- 每个工作有一个分支,每个分支属于一个城市。
起初我依赖递归,但它的可定制性不够(显然)确实无法获得我想要的数据。
我要么在输出数组中获取太多数据,或者几乎没有..我只是无法弄清楚这个可控制的,如果我能看到我正在尝试做的事情的例子那就太好了...
谢谢
Let me start out by saying I've tried to read the CakePHP book as much as I can for this particular topic, and for whatever reason, I just cannot figure this out.
I have a few models:
Person
- each person can have many jobs
- each job has one branch and each branch belongsTo one city.
At first I was relying on recursive, but its not customizable enough (obviously) do get the data that I want.
I either get WAY too much data in my output array, or hardly any at all.. I just can't figure this containable out, and if I could see an example of what I'm trying to do it would be great...
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
既然您已经从头到尾阅读了这本食谱,我不会与您一起了解所有基本细节,而只是尝试解释如何使用该容器。
您可以将容器与模型中的
find
函数一起使用。从您的控制器或直接从您的模型。大多数时候我使用控制器,所以我会给你一个例子,你将如何从那里做到这一点。我也尝试使用您的具体示例,以便您可以使用。
我希望这可以帮助您更多地了解可收容性。
since you've read the Cookbook up and down I won't go through all the basic details with you and just try to explain how to use the containable.
You can use the containable with the
find
-functions from your models. Either from your controller or directly from your model.Most of the time I use the controller so I will give you an example how you would do it from there. I also try to use your specific example, so you have something to work with.
I hope this helped you in understanding containable a little more.