And there will be many similar instances. Is there a better way to generate all these funcions? Is that good practice, or should they all be written out in a source file somewhere?sub getCustomerById { my $id = shift; my $dbh = sqlConnect(); my $sth = $dbh->prepare("SELECT * FROM customers WHERE cust_id=?") +; $sth->execute($id); my $result = $sth->fetchrow_hashref(); $sth->finish(); return $result; } sub getUserByUserId { my $id = shift; my $dbh = sqlConnect(); my $sth = $dbh->prepare("SELECT * FROM users WHERE user_id=?"); $sth->execute($id); my $result = $sth->fetchrow_hashref(); $sth->finish(); return $result; }
In reply to Code factory by Notromda
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |