in reply to Class::DBI question

I'm not sure what you imagined was going to happen when you called $entry->$hashref, but it doesn't work that way. $entry is an object, and you access it by calling method. If you want to update the fields foo, bar, and baz, you do this:
$entry->foo(7); $entry->bar('some string'); $entry->baz(23.5); $entry->update(); $entry->dbi_commit();

Replies are listed 'Best First'.
Re: Re: Class::DBI question
by freddo411 (Chaplain) on Oct 20, 2003 at 22:06 UTC
    What I'd like is a method called "update" that works like "create":

    # as yet wishfull thinking... my $cd = Music::CD->update({ cdid => 1, artist => $artist, title => 'October', year => 1980, });

    I'm surprized that one hasn't been written like this already. I may have to write this myself, but it would be nice not have to.

    -------------------------------------
    Nothing is too wonderful to be true
    -- Michael Faraday

      I'm surprized that one hasn't been written like this already. I may have to write this myself, but it would be nice not have to.
      Well, it's called set
      my $cd = Music::CD->retrieve( cdid => 1 ) or die "no cd 1"; $cd->set( artist => $artist, title => 'October', year => 1980, );
      update: that's why they call me PodMaster ;D

      MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
      I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
      ** The third rule of perl club is a statement of fact: pod is sexy.

        Yup, that's the ticket. Mea Culpa, it is in the docs, just not where I was looking for it.

        Thanks

        -------------------------------------
        Nothing is too wonderful to be true
        -- Michael Faraday