in reply to Getting HASHES out of Class::DBI
I'd have to ask, what do you need the hash for? If you really do need a hash, then yes, why are you using CDBI? Ideally you want to use the object, not the hash.
If you use CDBI objects most of the time but need the hash for a particular function, then you could add another method to your class:
Not Tested:
__PACKAGE__->set_sql( retrieve_hash => qq{ select * from __TABLE__ where id=? }, 'Main'); sub retrieve_hash { my ($class,$id) = @_; my $sth = $class->sql_retrieve_hash(); $sth->execute($id); my $hashref = $sth->fetchrow_hashref(); $sth->finish; return $hashref; }
again, though, I would recommend having a close look at your hash usage to see if it can't be modified to use the object instead.
cheers,
J
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Getting HASHES out of Class::DBI
by jdtoronto (Prior) on Jan 07, 2004 at 02:18 UTC | |
by perrin (Chancellor) on Jan 07, 2004 at 04:17 UTC | |
by jdtoronto (Prior) on Jan 07, 2004 at 04:35 UTC | |
by knowmad (Monk) on Jan 07, 2004 at 13:36 UTC |