Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-10-2007, 12:08 PM
Junior Member
 
Join Date: Jun 2007
Posts: 6
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 06-10-2007, 02:22 PM
Junior Member
 
Join Date: Jun 2007
Posts: 3
Default

DB Select Manual

Example 9.53 looks like just what you want.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 06-10-2007, 02:54 PM
Junior Member
 
Join Date: Jun 2007
Posts: 6
Default

Quote:
Originally Posted by CopaceticOpus View Post
DB Select Manual

Example 9.53 looks like just what you want.
That's perfect, it's also embarrassingly directly below the section which I used to work out how to do OR.

Thanks again,

Andrew
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 03:03 AM.