in reply to Re: Code factory
in thread Code factory
My select sub (part of Coruscate::DB (not on cpan) package):
sub select { my ($self, $want, $query, @args) = @_; die "Not connected to a database!" unless defined $self->{'dbh'}; my $results; if (ref $want eq "HASH") { my $sth = $self->{'dbh'}->prepare("SELECT $query"); $sth->execute(@args); while (my $row = $sth->fetchrow_hashref()) { push @{$results}, { map { $_, $row->{$_} } keys %{$row} }; } } elsif (ref $want eq "ARRAY") { $results = $self->{'dbh'}->selectall_arrayref("SELECT $query", {}, @ +args); undef $results if $#{$results} < 0; } return $results; }
I absolutely love my little module. Extremely simple interface that can do everything. Sweet :)
If the above content is missing any vital points or you feel that any of the information is misleading, incorrect or irrelevant, please feel free to downvote the post. At the same time, please reply to this node or /msg me to inform me as to what is wrong with the post, so that I may update the node to the best of my ability.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Re: Code factory
by duct_tape (Hermit) on Jul 08, 2003 at 14:36 UTC | |
by tadman (Prior) on Jul 08, 2003 at 19:01 UTC | |
by Notromda (Pilgrim) on Jul 09, 2003 at 01:55 UTC | |
by duct_tape (Hermit) on Aug 26, 2003 at 20:03 UTC |