in reply to Re: Pearls (not really) of Perl programming
in thread Pearls (not really) of Perl programming
I've actually used:
$sql = '... WHERE 1=1'; $sql .= ' AND ...' if (...); $sql .= ' AND ...' if (...); $sql .= ' AND ...' if (...);
In defense, 1) it wasn't in Perl, which has the convenient join function, and 2) the conditions where not already in an array as in the above snippet.
For the following, though, I deserve to be shot:
if (0 || ... || ... || ... ) { ... }
I do it just so all the conditions line up nicely.
Update: That should be WHERE 1=1 (not WHERE 1) because 1 does not mean true in SQL, or at least not for the database I was using.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Pearls (not really) of Perl programming
by dimar (Curate) on Nov 24, 2004 at 22:30 UTC | |
by Mutant (Priest) on Nov 25, 2004 at 09:29 UTC | |
|
Re^3: Pearls (not really) of Perl programming
by itub (Priest) on Nov 24, 2004 at 20:02 UTC | |
|
Re^3: Pearls (not really) of Perl programming
by bart (Canon) on Nov 25, 2004 at 11:57 UTC | |
|
Re^3: Pearls (not really) of Perl programming
by cosimo (Hermit) on Nov 25, 2004 at 12:33 UTC |