in reply to Passing database handles
An interesting idea might be:
I suggest to evaluate returncodes if there's the slightest possibility that an error happenes, so nearly all the time.my $result = $dbh->SelectProfile($id); .... package DBI; # or whatever package shell be extended sub SelectProfile { my ($self, $id) = @_; # $self is $dbh my $selectquery = "SELECT * FROM people WHERE id = '$id'"; my $sth= $self->prepare($selectquery) or die "Error in prepare: $DBI::errstr\n"; $sth->execute() or die "Error in execute: $DBI::errstr\n"; my $rowdata=$sth->fetchrow_hashref; $self->disconnect; # imho better done in main-program... + return $rowdata; }##END SelectProfile
Best regards,
perl -e "print a|r,p|d=>b|p=>chr 3**2 .7=>t and t"
|
|---|