 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
| l |
Sometimes it's
not easy to hold all your handles
|
|
|
|
– |
e.g., library
code to lookup values from the database given a $dbh
|
|
|
| l |
The prepare_cached()
method gives you a client side
|
|
|
statement handle
cache:
|
|
|
|
while
( ($field, $value) = each %search_fields ) {
|
|
|
|
push @sql, "$field = ?";
|
|
|
|
push @values, $value;
|
|
|
|
}
|
|
|
|
$where = "";
|
|
|
|
$where = "where ".join("
and ", @sql) if @sql;
|
|
|
|
$sth =
$dbh->prepare_cached("select * from table $where");
|
|
|
|
$sth->execute(@values);
|
|
|
| l |
Can avoid the
need for global statement handle variables
|
|