Don*_*Den 7 php zend-framework doctrine-orm
我正在使用Doctrine 2.3我面临着为以下场景设计查询的困难.
SELECT * FROM source WHERE source_id ='10' or source_id ='100' or source_id ='30'
Run Code Online (Sandbox Code Playgroud)
我为单身ID选择做了这个,但我不知道如何做到这一点.
$qry = $this->manager()->create()
->select('e')
->from($this->entity, 'e')
->where('e.id = :id');
Run Code Online (Sandbox Code Playgroud)
有人可以帮助我吗?如果我知道上述查询的工作,我将解决我的其他问题..如下.
SELECT * FROM source WHERE source_id ='10' and source_name ='test' and source_val ='30'
Run Code Online (Sandbox Code Playgroud)
Rik*_*esh 12
首先要改变你的where子句,比如
->where('e.id IN (:ids)')
->setParameter('ids', $ids)
Run Code Online (Sandbox Code Playgroud)
哪里 $ids = array('10','100','');
并使用和条件为您的第二个查询它应该是,像,
$qry = $this->manager()->create()
->select('e')
->from($this->entity, 'e')
->where('e.source_id = :id')
->andWhere('source_name=?', 'test')
->andWhere('source_val=?', '30')
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11011 次 |
| 最近记录: |