php - Zend framework query where clause -
i have following query searching tables car model no , category name
select * cars car left join categories cat on cat.car_id = car.car_id (car.model_no '%gt v8%') or (cat.name '%gt v8%')
i using zend framework have query far in model
$sql = $this->select()->setintegritycheck(false) ->from(array('car'=>$this->_name), array()) ->joinleft(array('cat'=>'categories'), 'cat.car_id=car.car_id', array())
then in clause
i this
$sql->where('car.model_no ?', '%'.$query['search'].'%') ->where('cat.name ?', '%'.$query['search'].'%')
but output
where (car.model_no '%gt v8%') , (cat.name '%gt v8%')
i can't find way replace , or.. there anyway in zend_db?
use orwhere (example #19)
$sql->where('car.model_no ?', '%'.$query['search'].'%')->orwhere('cat.name ?', '%'.$query['search'].'%')
from docs:
if need combine terms using or, use orwhere() method. method used in same way where() method, except term specified preceded or, instead of and.
Comments
Post a Comment