我正在获取具有多对多关系的数据,并且我想定义一个自定义方法。是否有可能(以及如何)使用类似的东西:
$hotel = $entityManager->getRepository('Hotels')->findOneById(1);
$types = $hotel->getTypes(); //$types is instance of **Doctrine\ORM\PersistentCollection**
$types->myCustomFunction(); //do something
我正在获取具有多对多关系的数据,并且我想定义一个自定义方法。是否有可能(以及如何)使用类似的东西:
$hotel = $entityManager->getRepository('Hotels')->findOneById(1);
$types = $hotel->getTypes(); //$types is instance of **Doctrine\ORM\PersistentCollection**
$types->myCustomFunction(); //do something
它似乎尚未实施。
请参阅此 Doctrine 的 JIRA 问题: http: //www.doctrine-project.org/jira/browse/DDC-547
考虑允许自定义 PersistentCollection 实现
我们应该考虑允许在每个关联的基础上配置自定义 PersistentCollection 实现。这可以让用户在不更改域模型代码的情况下为其某些集合设计优化 (SQL) 行为以提高性能。
为此,需要为继承设计 PersistentCollection。