well, yeh, kinda.. but maybe it sounds better if you turn that around to say that Class::DBI turns your records into objects. I think you would find it to be a huge head start for what you want from your abstraction layer.
As for granular, once you've got your classes set up it's quite simple to create custom sql queries.
The main performance hit that I watch is if you are doing a search that will return a large number of results. In this case Class::DBI takes the data from each record and initialises it into an object. If I just want the data then I write a customised query and method to go with it and return either the select handle or an array of hashes (or array of arrays..) which avoids 90% of the extra overhead Class::DBI would naturally impose.
__PACKAGE__->set_sql( list => "select uname,fname,sname from users" );
sub list{
my ($class) = @_;
my $sth = $class->sql_list();
$sth->execute();
return $sth->fetchall_arrayref({});
}
Update: oops.. corrected code above..
and when you want the user list..
my @users = My::CDBI::User->list;
With the common task of grabbing one record the automatic objectifying is great and makes it really simple to access/modify records.
my $user = My::CDBI::User->retrieve(123);
$user->fname('Fred');
$user->sname('Flintstone');
$user->update;
cheers,
J |