Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

use zend db with whare and orwhere when orwhere are in ()

hi i want create this sql in zend framework dbclass

selec * from table where type = 2 AND (name LIKE '%4%' OR name LIKE '%5%')

how i can do this with zend where and orwhere?

using normal mode will generate this sql

 $this->select()->from($this->_name)->where('type = ?', $type)->orwhere('name LIKE ?', '%'.4.'%');

this is not what i need

also i think i can use having in this case , is this a good idea?

like image 885
Silverboy.ir Avatar asked Jan 14 '23 09:01

Silverboy.ir


1 Answers

You want:

$this->select()
     ->from($this->_name)
     ->where('type = ?', $type)
     ->where('name LIKE ? OR name LIKE ?', array('%'.4.'%', '%'.5.'%');
like image 81
Tim Fountain Avatar answered Mar 16 '23 10:03

Tim Fountain