How I do it is:
How I'd like to do it is abstract it away into comparison objects where stringifying it will mix in the AND and ORs, and maybe a list context for binding. But I've not stopped to think about it long enough to write any code for it :-)if (some_perl_code_condition) { push @where, 'a.somedata5 <= ?'; push @bind, $somedata5_max } # ... $sql = $select . join(' AND ', @where) . $order; # and use @bind for the execute statement
Of course, I'll end up with a unique statement nearly each time through, so preparing becomes nearly useless (from a performance perspective anyway - almost may as well use do...), which may be a different concern.
Update: Added italicised pieces in last paragraph in response to graff.
In reply to Re: Perl style/best practice question: how to [better] embed SQL in code ?
by Tanktalus
in thread Perl style/best practice question: how to [better] embed SQL in code ?
by Krambambuli
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |