Beefy Boxes and Bandwidth Generously Provided by pair Networks Joe
The stupid question is the question not asked
 
PerlMonks  

Re: Class::DBI strangeness...

by duct_tape (Hermit)
on Dec 19, 2003 at 15:47 UTC ( [id://315907]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Class::DBI strangeness...

Hello,

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:

... foreach ( $usr->columns ) { $output .= "<b>$_</b>; " . $usr->$_ . "<br>"; } ...

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.


Regards,
Bradley C Bailey

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://315907]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.