Zend Framework 2 Sql Wybierz za pomocą OR i AND

Chcę utworzyć to zapytanie za pomocą Zend Db sql Wybierz:

SELECT table1.* FROM table1 
    INNER JOIN table2 ON table1.columnA = table2.columnB 
    INNER JOIN table3 ON table1.columnC = table3.columnD

WHERE (table2.column2 = 2 or table3.column3 = 3) and table1.column1 = 1

ORDER BY table1.columnE ASC LIMIT 1

Mam do tej pory ten kod:

/*@var $db Adapter */
$db = $this->getServiceLocator()->get('db');
$sql = new Sql($db);
$select = $sql->select();

$select->from('table1');
$select->join('table2','table1.columnA = table2.columnB',array());
$select->join('table3','table1.columnC = table3.columnD',array());

$select->where(array('table2.column2' => 2, 'table2.column3' => 3), Predicate\PredicateSet::OP_OR);

$select->where(array('table1.column1' => 1),Predicate\PredicateSet::OP_AND);

$select->order('table1.columnE ASC');
$select->limit(1);

$statement = $sql->prepareStatementForSqlObject($select);
$resultSet = $statement->execute();

Ale nie działa, ponieważ wyprodukuj ten (bez „(„ i ”)” dla OR):

SELECT table1.* FROM table1 
    INNER JOIN table2 ON table1.columnA = table2.columnB 
    INNER JOIN table3 ON table1.columnC = table3.columnD

WHERE table2.column2 = 2 or table3.column3 = 3 and table1.column1 = 1

ORDER BY table1.columnE ASC LIMIT 1

Co mogę zrobić?

questionAnswers(2)

yourAnswerToTheQuestion