I'm using Class::DBI in my perl code to provide an OO interface to my simple DB table. The application is a classic CRUD pattern (create/retrieve/update/delete).
I've successfully set up my table, and have retrieved data, created data, and deleted data. I'm having trouble figuring how to update a record with the OO methods. The Class::DBI docs show only one example of an update, and in that one it simply updates a single field. I have a hash containing fieldnames/values and would like to pass it all at once.
Can anyone provide an example, or point me to method code to accomplish this?
# Various stuff above to use Class::DBI and set it up # verified to work by retrieving # Put the validated fields into the DB # New, unique ID number is automagically generated # if needed my $hashref = $results->valid; my %hash = %$hashref; my $foo = $hash{'id'}; carp "ID is: $foo "; my $entry = Contacts->find_or_create( id => $foo ); $entry->$hashref; # this doesn't work $entry->dbi_commit(); $entry->update;
-------------------------------------
Nothing is too wonderful to be true
-- Michael Faraday
In reply to Class::DBI question by freddo411
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |