Just another Perl shrine | |
PerlMonks |
Re^3: Class::DBI - my way is not very sportsmanlikeby perrin (Chancellor) |
on Dec 03, 2004 at 14:25 UTC ( [id://412136]=note: print w/replies, xml ) | Need Help?? |
If you dislike having SQL generated for you, you may be happier just using Ima::DBI directly. It doesn't turn your data into objects, but it sounds like you don't really care about that as much as setting the SQL manually. If you do want to keep Class::DBI and set your INSERT manually, I think you can actually override the MakeNewObj SQL which is set through a set_sql call at the top of Class::DBI. The has_many() stuff does a few things for you. It handles cascading deletes, gives you a method for adding a new related object (add_to_*), and lets you restrict the set ( $prof->subjects(year => 2003) ) or set an order. Both has_many and has_a follow useful rules when fetching objects. They can turn your data into a Perl class (a DateTime object is the classic example), they use lazy-loading to avoid fetching data you don't usually need until you ask for it, and they will check to see if you already have any of the objects in memory and return the existing object instead of making a duplicate. In short, Class::DBI has grown to do quite a bit. If you want a very lightweight way of accessing data and saving it back out, there are other options that might be simpler.
In Section
Meditations
|
|