Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Problem with Class::DBI::SQLite up

by ColtsFoot (Chaplain)
on Feb 21, 2010 at 20:04 UTC ( [id://824527]=perlquestion: print w/replies, xml ) Need Help??

ColtsFoot has asked for the wisdom of the Perl Monks concerning the following question:

Brothers, first I must beg your forgiveness as I have been away for a while, but have again returned to the "TRUE WAY" I have the following code
my $textanswer = TextAnswer->create( response_id => $response_id, user => $user_id, answer => $answer); print qq(TextAnswer->textanswer_id => ), $textanswer->textanswer_id, q +q(<br />); print qq(TextAnswer->response_id => ), $textanswer->response_id, qq(<b +r />); print qq(TextAnswer->user => ), $textanswer->user, qq(<br />); print qq(TextAnswer->answer =>), $textanswer->answer, qq(<br />); print qq(CALLING UPDATE<br />); $textanswer->update; print qq(CALLED UPDATE<br />);
and in my Textanswer package I have
__PACKAGE__->add_trigger( after_create => sub { my ($self) = @_; print "ID = '$self->{textanswer_id}', Answer = '$self->{answer} <br + />"; }); __PACKAGE__->add_trigger( before_create => sub { my ($self) = @_; print "ID = '$self->{textanswer_id}', Answer = '$self->{answer} <br +/>"; }); __PACKAGE__->add_trigger( before_update => sub { my ($self) = @_; print "About to update album, '$self->{answer} <br />"; }); __PACKAGE__->add_trigger( after_update => sub { my ($self) = @_; print "Finished updating album '$self->{answer} <br />"; });
My output is as follows
ID = '', Answer = 'John Doe ID = '2', Answer = 'John Doe TextAnswer->textanswer_id => 2 TextAnswer->response_id => 1 TextAnswer->user => DOEJ1 TextAnswer->answer =>John Doe CALLING UPDATE CALLED UPDATE
So it seems that the before_update/after_update triggers aren't being fired and sure enough the update isn't updating the SQLite database. I think that too many years away from the "TRUE WAY" has clouded my thoughts
Has any brother an idea? Blessings

Replies are listed 'Best First'.
Re: Problem with Class::DBI::SQLite up
by Your Mother (Archbishop) on Feb 21, 2010 at 20:19 UTC

    I'm sorry to avoid answering your real question but if you've been away from this stuff for awhile you should look at DBIx::Class instead. I was an early adopter and frequent user of Class::DBI (CDBI) and have moved entirely to DBIx::Class (DBIC). It's a better ORM framework on many levels (speed, extensibility, code generation, and more).

    Unlikely but possible solution to your current problem: update your DBD::SQLite. It's had several rounds of updates and bug fixes in the last few months.

Re: Problem with Class::DBI::SQLite up
by jdrago999 (Pilgrim) on Feb 22, 2010 at 18:40 UTC

    $textanswer->update won't update anything unless you've actually changed something inside of your $textanswer object.

    Aside from that - Class::DBI hasn't seen much action lately. You may benefit from using DBIx::Class (completely new) or Class::DBI::Lite (more similar to Class::DBI).

    Disclaimer: I am the author of Class::DBI::Lite.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://824527]
Approved by Sinistral
Front-paged by Sinistral
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (5)
As of 2024-04-19 10:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found