Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Making a Class::DBI object reference

by edoc (Chaplain)
on Apr 03, 2004 at 13:22 UTC ( #342292=note: print w/replies, xml ) Need Help??


in reply to Making a Class::DBI object reference

ok, how about this..

When you want to create a new object, use 'create'.

my $object = My::CDBI::Class->create({ id => 1, label => 'example' });

When you already have a record in the database you want as an object, use 'retrieve'.

my $object = My::CDBI::Class->retrieve(1);

You could say that these two methods replace what you would normally think of as 'new's job, either taking the data from you or from the database to instantiate the object. You can now call methods on your object.

$object->label('new example'); $object->update;

cheers,

J

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://342292]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2022-01-21 08:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (57 votes). Check out past polls.

    Notices?