No such thing as a small change | |
PerlMonks |
Re^2: prepare statement within DBIby Smylers (Pilgrim) |
on Aug 26, 2004 at 14:27 UTC ( [id://386035]=note: print w/replies, xml ) | Need Help?? |
For most of the duplication you avoid with your fetch_count function, DBI has a built-in way of avoiding it: whenever you've got a query on which ->fetch_... is only invoked once, you can skip the separate ->prepare and ->execute by using a $db->select_... method. So the 4 active lines in your function become just 1:
It probably isn't worth writing a function for that, since there isn't that much duplication without it:
But you could always put it in some sort of loop:
(By the way, I think your ->fetch_arrayref is a typo.) Smylers
In Section
Seekers of Perl Wisdom
|
|