in reply to Double Database Search and Sort
You previously mentioned a Speedtrap has 1:N Comments. Given that, your question does not provide enough information about what you want.
btw, here's a trick to simply your if:
$query = 'WHERE 1=1'; $query .= " AND state='$state'" if ($state ne 'all'); $query .= " AND approved='$status'" if ($status ne 'all');
Also, as I mentioned before, escape your arguments!! Unless you want someone to inject a query that deletes or modifies your database... Use replaceable parameters (as shown previously) or use quote(), as shown here:
my $q_state = $dbh->quote($state); my $q_status = $dbh->quote($status); $query = 'WHERE 1=1'; $query .= " AND state=$q_state" if ($state ne 'all'); $query .= " AND approved=$q_status" if ($status ne 'all');
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Double Database Search and Sort
by awohld (Hermit) on Sep 25, 2004 at 04:22 UTC | |
by ikegami (Patriarch) on Sep 25, 2004 at 04:58 UTC |