in reply to How treat query elegantly and more?
DBIx::Class really is the way to go here (if your DB design is sane; if your design is poor then DBIC will have an impedance mismatch). Pseudo code-
my %query = ( some => "default relevant to controller" ); my @stuff = $c->request->param("some_checkbox_list"); $query{foo} = { in => \@stuff } if @stuff; $query{something} = "tacos" if $something_taco_related; # a dozen more similar style, disparate variable loads. my %where = ( some => "dynamic", list => "of conditions" ); my $rs = $c->model("DBIC::SomeTable") ->search(\%query, { join => [ blah, blah ], %where }); $c->stash( some_stuff_rs => $rs );
DBIC (and by extension, SQL::Abstract) shines when dynamic data drives your queries as well as when you need ready access through relationships.
Sidebar not relevant to this particular thread but a previous one: it's somewhat poor etiquette to ask the same question in three places at once (e.g., Cat list, PM, Stack Overflow). You should generally do one at a time and wait a day to see what answers you get or at least mention and link to the cross-posted question.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How treat query elegantly and more?
by xiaoyafeng (Deacon) on Jul 01, 2010 at 06:20 UTC | |
by Your Mother (Archbishop) on Jul 01, 2010 at 17:14 UTC | |
by metaperl (Curate) on Jul 02, 2010 at 19:08 UTC | |
|
Re^2: How treat query elegantly and more?
by xiaoyafeng (Deacon) on Jul 01, 2010 at 05:51 UTC |