View Single Post
  #1 (permalink)  
Old 06-10-2007, 12:08 PM
andrewtayloruk andrewtayloruk is offline
Junior Member
 
Join Date: Jun 2007
Posts: 8
Default Zend_Db_Select - Operator Precendence

Hi,

Can anyone help with understanding operator precedence with Zend_Db_Select;

The query I want to execute is

SELECT * FROM myTable WHERE a = 1 AND (b = 0 OR c = 0 OR d = 0);

I've tried a few combinations of:

$sql = $this->_db->select();
$sql->from('myTable', *);
$sql->where('a = ?', 1);
$sql->orwhere('b = ?', 0);
$sql->orWhere('c = ?', 0);
$sql->orwhere('d = ?', 0);

$sql = $this->_db->select();
$sql->from('myTable', *);
$sql->orwhere('b = ?', 0);
$sql->orWhere('c = ?', 0);
$sql->orwhere('d = ?', 0);
$sql->where('a = ?', 1);

etc...

But I can't get it right.

Thanks

Andrew
Reply With Quote