http://qs321.pair.com?node_id=342292


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