Update doesn't stick for enum?

[prev] [thread] [next] [Date index for 2004/09/28]

From: perl
Subject: Update doesn't stick for enum?
Date: 16:42 on 28 Sep 2004
This is probably something really silly, but my question on perl boards didn't get any answers.

I'm trying to use C:DBI to update an enum field in the database. Here's the outline of the code:

my $groupid = ...;
my $newvalue = ...;
foreach my $key (@somekeys) {
  my ($obj) = MyCDBI::Obj->search(groupid => $groupid, userid => $key);
  if (defined $obj) {
    if ($newvalue eq 'somevalue') {
      $obj->status(lc $newvalue);
    } elsif ($newvalue eq 'someothervalue') {
      $obj->status("something");
    } elsif ...
      ...
    }
    print "new value: ", $obj->status;
    $obj->update;
  } else {
    print "Not found";
  }
}
Now, the code runs, and prints the new value properly. But looking in the database, the new value doesn't get saved.

The definitions: (each in it's own file)

package MyCDBI::DBI;
use base 'Class::DBI';
__PACKAGE__->set_db('Main', 'dbi:mysql:cdbidb', 'user', 'pass');
1;

package MyCDBI::Obj;
use base 'MyCDBI::DBI';
use Apache::Reload;

__PACKAGE__->table('objs');
__PACKAGE__->columns(Primary => qw/userid orgid status/);
__PACKAGE__->has_a(userid => "MyCDBI::User");
__PACKAGE__->has_a(orgid  => "MyCDBI::Org");

1;

Other updates (to other non-enum fields, elsewhere in the code, in other pages), do work properly.  I'm not sure if this is related to the enum, or the scoping of $obj, but I just can't seem to get it to work.

Any hints or suggestions would be very welcome!

        -- 
        Dan

Update doesn't stick for enum?
perl 16:42 on 28 Sep 2004

Re: Update doesn't stick for enum?
William McKee 12:41 on 30 Sep 2004

Generated at 11:34 on 01 Dec 2004 by mariachi v0.52