学说通过关系发现
我在选择带有学说的数据子集时遇到问题。
我有 3 张桌子
地点 接触 Contact_location
联系人和位置表保存名称和 ID,而其他表仅保存 ID。例如:
Location
loc_id: 1
name: detroit
Contact
contact_id: 1
name: Mike
Contact_location
loc_id: 1
contact_id: 1
在学说中,位置和联系人表之间存在多对多关系,其中 contact_location 作为 ref_class。
我想做的是在我的位置页面上找到所有联系人,例如 loc_id = 1。
我尝试过:
$this->installedbases = Doctrine::getTable('contact')->findByloc_id(1);
希望学说能够看到该关系并得到它,但它没有。
我怎样才能在相关的相关表中进行学说搜索?我读到它可以使用 Findby 完成,但我发现文档不清楚。
I'm having trouble selecting a subset of data with doctrine.
I have 3 tables
Location
Contact
Contact_location
The contact and location tables hold a name and an id the other table holds only ID's. For instance:
Location
loc_id: 1
name: detroit
Contact
contact_id: 1
name: Mike
Contact_location
loc_id: 1
contact_id: 1
In doctrine there is a many to many relation between the location and contact tables with contact_location as the ref_class.
What i want to do is on my location page i want to find all contacts where for instance the loc_id = 1.
I tried:
$this->installedbases = Doctrine::getTable('contact')->findByloc_id(1);
hoping doctrine would see the relation and get it, but it does not.
How can i make doctrine search in relevant related tables? I read it can be done using Findby but i find the documentation unclear.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将
findByloc_id()
更改为findByLocId()
。该方法被魔法__call()
捕获。Change
findByloc_id()
tofindByLocId()
. The method is caught by magic__call()
.在表类上添加一个方法:
然后按如下方式调用它:
Doctrine 应该使用 refclass 为您执行内部联接。
Add a method on your table class:
then call it as follows:
Doctrine should use the refclass to perform the inner join for you.