Logical OR in doctrine2 getRepository->findBy()

﹥>﹥吖頭↗ 提交于 2019-12-22 09:18:14

问题


How can write query like in doctrine2

SELECT * from table where field = value1 or field = value2

I found something like

 $em->getRepository('myentitity')
           ->findBy(
               array('field' => 'value1','field'=>'value2'),        // $where 
             );

But I think it is AND .. Please suggest me Thanks


回答1:


try this

  $em->getRepository('myentitity')
       ->findBy(
           array('field' =>array( 'value1','value2'))        // $where 
         );

If you pass an array of values Doctrine will convert the query into a WHERE field IN (..) query automatically:



来源:https://stackoverflow.com/questions/16621483/logical-or-in-doctrine2-getrepository-findby

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!