doctrine2中的逻辑OR getRepository-> findBy()

alw*_*arn 4 php doctrine doctrine-orm

如何在doctrine2中编写查询

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

我发现了类似的东西

 $em->getRepository('myentitity')
           ->findBy(
               array('field' => 'value1','field'=>'value2'),        // $where 
             );
Run Code Online (Sandbox Code Playgroud)

但我认为这是和..请建议我谢谢

moh*_*pur 10

试试这个

  $em->getRepository('myentitity')
       ->findBy(
           array('field' =>array( 'value1','value2'))        // $where 
         );
Run Code Online (Sandbox Code Playgroud)

如果传递一个值数组,Doctrine会自动将查询转换为WHERE字段IN(..)查询: