SELECT * FROM `table` WHERE `sex`= "male" AND (`age` > 18 OR `hobby` = "sport");
$this->select() ->where( "sex = ?", "male" ) ->where( "age > ?", 18, "INTEGER" ) ->orWhere( "hobby = ?", "sport" );
SELECT `table`.* FROM `table` WHERE (`table`.`sex`= "male") AND (`table`.`age` > 18) OR (`table`.`hobby` = "sport");
$select = $this->select(); $condition = $select->orWhere( "age > ?", 18, "INTEGER" ) ->orWhere( "hobby = ?", "sport" ) ->getPart( Zend_Db_Select::WHERE ); $condition = is_array( $condition ) ? implode( " ", $condition ) : $condition; $select->reset( Zend_Db_Select::WHERE ); $select->where( "sex = ?", "male" ) ->where( $condition );
Source: https://habr.com/ru/post/111918/