[CDBI] Was it deleted?

Bill Moseley moseley at hank.org
Thu Sep 21 04:06:22 BST 2006


How do I know that $foo->delete actually deletes the object in the
database?

    my $foo = Foo->retrieve($id);

    # some other session deletes the row from the database

    $foo->delete;



Shouldn't this check the row count?


sub delete {
        my $self = shift;
        return $self->_search_delete(@_) if not ref $self;
        $self->remove_from_object_index;
        $self->call_trigger('before_delete');

        eval { $self->sql_DeleteMe->execute($self->id) };
        if ($@) {
                return $self->_db_error(
                        msg    => "Can't delete $self: $@",
                        err    => $@,
                        method => 'delete'
                );
        }
        $self->call_trigger('after_delete');
        undef %$self;
        bless $self, 'Class::DBI::Object::Has::Been::Deleted';
        return 1;
}





-- 
Bill Moseley
moseley at hank.org




More information about the ClassDBI mailing list