如何使用带有Zend_Db_Table的Zend many to many relationships和联结表?是否存在提供此虚构性的内置方法或必须编写简单的SQL?
答案 0 :(得分:0)
它在文档中:Fetching a Rowset via a Many-to-many Relationship
要获取一行:
$row->findManyToManyRowset($table,
$intersectionTable,
[$rule1,
[$rule2,
[Zend_Db_Table_Select $select]
]
]);
// Example
$productsRowset = $bug1234->findManyToManyRowset('Products',
'BugsProducts');
// Here, BugsProducts is the junction table
但是,对于一对多关系,您还需要在类中定义关系:Defining relationships。