"be consistent" | |
PerlMonks |
Class::DBI find_or_create method inserts record but $obj->id is undefby jerrygarciuh (Curate) |
on Jan 23, 2004 at 23:46 UTC ( [id://323738]=perlquestion: print w/replies, xml ) | Need Help?? |
jerrygarciuh has asked for the wisdom of the Perl Monks concerning the following question:
Honored monks, I am making the administrative methods for a largish educational project using Class::DBI, Template-Toolkit, and CGI::Application. I have had three occasions now when attempting to use the sequence
If I set $id explicitly to undef then the Class::DBI record object $obj has the new record's row in $obj->id after find_or_create(). Thing is I need to check @_ and $q->param() for $id. Now, if either @_ or $q->param() has a value for $id, the the record gets appropriately put into $obj, altered in my foreach and then updated by $obj->update; The bug shows up when $q->param and @_ do not have a value for $id. Class::DBI's find_or_create() inserts the new row in the db but $obj->id is undef, and consequently the $obj->update does no good. So my question to you is how best to do this. Should I make a test for the contents of $id and set it explicitly to undef if it fails? What is a Good way to do this?TIA jg
_____________________________________________________ "The man who grasps principles can successfully select his own methods. The man who tries methods, ignoring principles, is sure to have trouble. ~ Ralph Waldo Emerson
Back to
Seekers of Perl Wisdom
|
|