Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: if/else options

by JavaFan (Canon)
on Aug 20, 2009 at 11:52 UTC ( [id://790070]=note: print w/replies, xml ) Need Help??


in reply to if/else options

my @clauses; push @clauses, 'column1' if defined $var1; push @clauses, 'column2' if defined $var2; push @clauses, 'column3' if defined $var3; my $query = "select * from table"; if (@clauses) { $query .= " where " . join ' and ', map {"$_ = ?"} @clauses } my $result = $dbi->selectall_arrayref($query, {}, grep {defined} $var1 +, $var2, $var3);

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://790070]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (2)
As of 2024-04-25 21:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found