in reply to Code factory
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); }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Code factory
by flounder99 (Friar) on Jul 07, 2003 at 18:07 UTC |