2014-06-26 29 views
0

是否可以在諸如findBy函數之類的函數中傳遞對象以檢索數據?在原則中查找對象:FindBy(Object)

注意:** $ resto對象沒有** id屬性填充。 因此,教義必須找到最接近的匹配條目。

例如:

 $resto = new Restaurant(); 
     $resto->setName('...') 
     ... 


     $repository = $this->getDoctrine()->getRepository('LesDataBundle:Restaurants'); 
     $result = $repository->findBy($resto); 
+0

定義 '最匹配的入口' 吧。另外,除非你使用'$ this-> getDoctrine() - > getManager() - > persist($ resto)'和$ this-> getDoctrine() - > getManager(),否則不能從數據庫中檢索'$ resto'。 - >先flush()。 – reafle

回答

0

沒有,但你可以使用自定義表達式

$repository->findBy([ 
    'some_field' => $resto->getSomeField(), 
    'other_field' => $resto->getOtherField() 
]); 
相關問題