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
In reply to Re: Getting HASHES out of Class::DBI
by edoc
in thread Getting HASHES out of Class::DBI
by jdtoronto
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |