I have this object:
$select = $this->_db->select()
                        ->from( 'table')
                        ->order('id ASC')
                        ->orWhere('type = 1')
                        ->orWhere('type = 2')
                        ->where('country = 1')
;       
_die( $select->__toString() );

This one generates this sql string
SELECT `table`.* FROM `table` WHERE (type = 1) OR (type = 2) AND (country =
1) ORDER BY `id` ASC.

But this is not what I wanted or imagined that the orWhere() will give me. 
What I want is this:
$select = $this->_db->select()
                        ->from( 'table')
                        ->order('id ASC')
                        ->where('type = 1 OR type= 2')
                        ->where('country = 1')
                ;       
                _die( $select->__toString() );
Meaning the OR conditions work in a group of their own, 
SELECT `table`.* FROM `table` WHERE (type = 1 OR type= 2) AND (country = 1)
ORDER BY `id` ASC

Is there a way of generating the OR condition without preparing the link by
hand?

-- 
View this message in context: 
http://www.nabble.com/understanding-Zend_Db_Table_Select%28%29--tp20249345p20249345.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to