Re: Need help with PHP & MySQL
by "Darrell King" <darrell(at)webctr.com>
|
Date: |
Sat, 4 May 2002 09:30:14 -0400 |
To: |
<hwg-techniques(at)hwg.org> |
References: |
rudy |
|
todo: View
Thread,
Original
|
|
Now see, you've gone and made us need to do all kinds clocking on 20 test
platforms to see which is more efficient and...
Nah...too much work...:).
Actually, I use the array approach for more complex WHERE clauses and JOIN
combinations, so it's just a natural for me to fall back on it in a
situation like this. It doesn't really get interesting until there are ANDs
mixed with ORs from different tables.
Most welcome of all, though, is the mingling of ideas...:).
D
----- Original Message -----
From: "rudy" <r937(at)interlog.com>
> When you have multiples like that, you need to first check whether
> there should even by a WHERE in the query. If all the clauses are
> empty, then the WHERE stands alone and that is a BAD thing.
that was my point, starting the WHERE clause off with 1=1
that way you can start off each subclause with AND
otherwise you have to have extra logic to find out which one of the
subclauses is the first one that's actually included
for example, you can have
where conditionA and conditionB
or
where conditionB and conditionC and conditionD
or
where conditionD
so when you are testing whether to add conditionD,how would you know if any
of the previous subclauses are there without some additional programming
logic?
of course, php programmers love switches and logic, so...
[ducks]
that array trick is pretty neat, darrell
rudy
HWG hwg-techniques mailing list archives,
maintained by Webmasters @ IWA