>
> How I do it:
>
> $model = new tblModel();
> $select = $model->select();
> $select->where('(x=1 OR x=2)');
> $select->where('(y=1 OR y=2)');
>
>
> ViktorG wrote:
>>
>> Hi,
>>
>> I would like to do something like:
>>
>> SELECT * FROM tbl WHERE (x = 1 OR x = 2) AND (y = 1 OR y = 2);
>>
>> Is this possible by using the Zend DB Table Object?
>>
>
>
Thanks for the replies. I already thought that this would be the only way.
So nesting is not supported. Otherwise I could do something like:
$select->where($select->orWhere('x=?',1)->orWhere('x=?',2));
$select->where($select->orWhere('y=?',1)->orWhere('y=?',2));
@Till
No, the keys are not primary ones, the real use case ist more like:
$sSearch = 'Bill Gates'; // user input
$aSearch = explode(' ', $sSearch);
$oModel = new tblModel();
$oAdapter = $oModel->getAdapter();
$oSelect = $oModel->select();
foreach($aSearch as $sSearchPart){
$sSearchPart = $oAdapter->quote($sSearchPart);
$oSelect->where('(forname LIKE ' . $sSearchPart . ' OR surename LIKE ' .
$sSearchPart . ')');
}
Thanks
--
View this message in context: http://www.nabble.com/nesting-conditions-tp20940516p20951297.html
Sent from the Zend DB mailing list archive at Nabble.com.
没有评论:
发表评论