Re: DataObject: How to create SQL AND & OR
| From: | Luca Giandoso | Date: | Wed, 17 Jan 2007 13:23:09 +0000 |
| Subject: | Re: DataObject: How to create SQL AND & OR | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-26359@lists.php.net to get a copy of this message | ||
To obtain:
SELECT * FROM Persons WHERE
(FirstName='Tove' OR FirstName='Stephen')
AND LastName='Svendson'
you can use
$O->whereAdd('FirstName = Tove OR FirstName = Stephen');
$O->whereAdd('LastName = Svendson', 'AND');
Is it right for you?
On 1/17/07, Simon Brüchner <simon@tattoobedarf.de> wrote:
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 "()" :( -- PEAR General Mailing List (http://pear.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php