For Programmers: Free Programming Magazines  


Home > Archive > PHP Pear > January 2007 > Re: [PEAR] 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 Re: [PEAR] DataObject: How to create SQL AND & OR
Luca Giandoso

2007-01-17, 7:00 pm

To obtain:
SELECT * FROM Persons WHERE
(FirstName=3D'Tove' OR FirstName=3D'Stephen')
AND LastName=3D'Svendson'

you can use

$O->whereAdd('FirstName =3D Tove OR FirstName =3D Stephen');
$O->whereAdd('LastName =3D Svendson', 'AND');

Is it right for you?

On 1/17/07, Simon Br=FCchner <simon@tattoobedarf.de> wrote:
> How can I get a query like:
>
> SELECT * FROM Persons WHERE
> (FirstName=3D'Tove' OR FirstName=3D'Stephen')
> AND LastName=3D'Svendson'
>
> How to get the "()" arround the OR?
>
> Sample code:
> ...
> $O->whereAdd('FirstName =3D Tove', 'OR');
> $O->whereAdd('FirstName =3D Stephen', 'AND');
> $O->whereAdd('LastName =3D Svendson', 'AND');
> ...
>
> creates
>
> SELECT * FROM Persons WHERE
> FirstName=3D'Tove' OR FirstName=3D'Stephen'
> AND LastName=3D'Svendson'
>
> No "()"
> :(
>
> --
> PEAR General Mailing List (http://pear.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Sponsored Links







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

Copyright 2008 codecomments.com