简体   繁体   English

表数据网关,级联一对多和Zend

[英]Table Data Gateway, Cascading one-to-many, and Zend

I am new to Zend Framework and OO design patterns. 我是Zend Framework和OO设计模式的新手。

I have three tables: Owners, Shops and Products. 我有三张桌子:业主,商店和产品。 One Owner has many Shops; 一位业主有很多商店; and each Shop has many Products. 每个商店都有很多产品。

I have extended Zend's DB Table Abstract for each of the three tables, and setup dependent tables and reference maps. 我已经为三个表中的每一个扩展了Zend的DB Table Abstract,以及设置依赖表和参考映射。

If I want to find which Products are available from a particular Owner, I start with an Owner object and use findDependentRowset to get a rowset of Shops. 如果我想查找特定所有者可用的产品,我将从Owner对象开始,并使用findDependentRowset获取Shops的行集。 I then iterate the rowset to find all Products (again using findeDependentRowset). 然后我迭代行集以查找所有产品(再次使用findeDependentRowset)。

Is there a shortcut for doing this? 这样做有捷径吗? How do you go about navigating three such tables using the Table Data and Row Data Gateway patterns? 您如何使用表数据和行数据网关模式导航三个这样的表? (Or should I be moving to a Data Mapper perhaps?) (或者我应该转向数据映射器?)

Thanks for your thoughts! 谢谢你的想法!

I think what you can use is findManyToManyRowset method. 我认为你可以使用的是findManyToManyRowset方法。

For example to find produces for a given owner you could be able do: 例如,要查找给定所有者的产品,您可以执行以下操作:

$productsRowset = $ownerRow->findManyToManyRowset('Products_Table_Model','Shops_Table_Model');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM