Now you can call this function with the appropriate parameters, or, try and make these wrapper functions:sub getById { my ($table, $column, $id) = @_; my $dbh = sqlConnect(); my $sth = $dbh->prepare("SELECT * FROM $table WHERE $column=?"); $sth->execute($id); my $result = $sth->fetchrow_hashref(); $sth->finish(); return $result; }
This can be tuned to match any of your various "getXById" functions by simply supplying different parameters.sub getCustomerById { my ($id) = @_; return getById("customers", "cust_id", $id); }
In reply to Re: Code factory
by tadman
in thread Code factory
by Notromda
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |