Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Making a Class::DBI object reference

by edoc (Chaplain)
on Apr 03, 2004 at 13:22 UTC ( [id://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?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-04-19 02:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found