From: Chris W. <ch...@cw...> - 2004-01-05 16:02:18
|
On Jan 5, 2004, at 10:43 AM, Igor Sutton Lopes wrote: > I'm having a trouble obtaining the object's id after saving it. > According > documentation you should use something like: > > my $obj = eval { $empresa->save }; > > $id_empresa = $obj->id_empresa; > > But it is always returning undef. > > I'm using SPOPS (the last version from CPAN) and Perl 5.8.0. Try: my $new_id = $obj->id; Also, if you're using auto-incrementing fields this may mean you're not using the right SPOPS DBI implementation. In your configuration you must have the right implementation for the driver (e.g., 'SPOPS::DBI::MySQL') as well as the field 'increment_field' set to a true value, like in this example: my %conf = ( object => { class => 'My::Object', isa => [ qw/ SPOPS::DBI::MySQL SPOPS::DBI / ], field => [ qw/ id_empressa foo bar / ], id_field => 'id_empressa', increment_field => 'yes', base_table => 'empressa' }, ); And if you're using Oracle/Postgres you need to specify a sequence name as well. Good luck! Chris -- Chris Winters Creating enterprise-capable snack systems since 1988 |