Re: Need help with PHP & MySQL
by "rudy" <r937(at)interlog.com>
|
Date: |
Sat, 4 May 2002 09:17:47 -0400 |
To: |
"Darrell King" <darrell(at)webctr.com>, <hwg-techniques(at)hwg.org> |
|
todo: View
Thread,
Original
|
|
> 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