For Programmers: Free Programming Magazines  


Home > Archive > PHP Pear > January 2007 > DataObject: How to create SQL AND & OR









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author DataObject: How to create SQL AND & OR
Simon Brüchner

2007-01-17, 8:02 am

How can I get a query like:

SELECT * FROM Persons WHERE
(FirstName='Tove' OR FirstName='Stephen')
AND LastName='Svendson'

How to get the "()" arround the OR?

Sample code:
....
$O->whereAdd('FirstName = Tove', 'OR');
$O->whereAdd('FirstName = Stephen', 'AND');
$O->whereAdd('LastName = Svendson', 'AND');
....

creates

SELECT * FROM Persons WHERE
FirstName='Tove' OR FirstName='Stephen'
AND LastName='Svendson'

No "()"
:(
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com