5
我使用多對多關係獲取數據,我想定義acustom方法。是否有可能(以及如何)使用類似的東西:在Doctrine ORM PersistentCollection中定義自定義方法
$hotel = $entityManager->getRepository('Hotels')->findOneById(1);
$types = $hotel->getTypes(); //$types is instance of **Doctrine\ORM\PersistentCollection**
$types->myCustomFunction(); //do something
我不想使用存儲庫,因爲我需要使用多對多的關係而已。我想創建類似'$ hotel-> getTypes() - > fetchPair()' – user1518183
對不起,我誤解了這個問題,你可能想結賬http://stackoverflow.com/questions/3691943/custom-collection-in -doctrine2雖然 – max
謝謝,我試過了,但這並不能解決我的問題。我需要調用Doctrine \ ORM \ PersistentCollection實例的對象上的自定義方法(當我獲取多對多關係時,我得到了這個方法)。 – user1518183