|P is for Practical|
Re: Class::DBI strangeness...by duct_tape (Hermit)
|on Dec 19, 2003 at 20:47 UTC||Need Help??|
In the Class::DBI pod there is a section about LAZY POPULATION. Basically it loads as little as possible into the object in hopes to increase performance.
Assuming you specified all the columns that you want in the All (or Essential) group in your columns() call, whenever you make a call to any column accessor it will load the rest of them into object as well. So you can change your code to the following without worrying that it is querying the database for every column:
To see this in action, call $usr->upusername and then dump the $usr object and in theory it should also have the rest of the columns in it as well.
I have also noticed that when you call create() with all the columns, it only returns back an object with the primary key in it. I assume it does this type of stuff in case you have triggers set up in your database that did something with the columns after you inserted them. Just a guess though...
Take my comments with a grain of salt... I've only been playing around with CDBI for less than a week, so I am not too experienced with it. But I hope I am of some help.
Bradley C Bailey