douquejituan938904 2013-06-04 06:04
浏览 39
已采纳

学说多重条件

I am Working with Doctrine 2.3 I am facing difficulty to design a Query for the below scenario.

SELECT * FROM source WHERE source_id ='10' or source_id ='100' or source_id ='30'

I did this for single Id selection but I am not sure how to do this.

$qry = $this->manager()->create()
        ->select('e')
        ->from($this->entity, 'e')
        ->where('e.id = :id');

Can some one help me in this? If I get to know the working for the above query I will solve my other issues.. As Follows.

 SELECT * FROM source WHERE source_id ='10' and source_name ='test' and source_val ='30'
  • 写回答

3条回答 默认 最新

  • dongye9453 2013-06-04 06:10
    关注

    For first one change your where clause like,

    ->where('e.id IN (:ids)') 
    ->setParameter('ids', $ids)
    

    Where $ids = array('10','100','');

    And to use and condition for your second query it should be something like,

    $qry = $this->manager()->create()
           ->select('e')
           ->from($this->entity, 'e')
           ->where('e.source_id = :id')
           ->andWhere('source_name=?', 'test')
           ->andWhere('source_val=?', '30')
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 组策略中的计算机配置策略无法下发
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)