Grokbase
Topics Posts Groups | in
x
[ help ]

[CDBI] Was it deleted?

View PostFlat  Thread  Threaded | Next >
Bill Moseley [CDBI] Was it deleted?
| +1 vote
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
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
[email protected: mo...@hank.org]


_______________________________________________
ClassDBI mailing list
[email protected: Cla...@lists.digitalcraftsmen.net]
http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi

Thread : [CDBI] Was it deleted?
1)
Bill Moseley How do I know that $foo->delete actually deletes the object in the database? my $foo =...
2)
Edward J. Sabol Bill Moseley asked: You mean the number of rows affected by the SQL delete statement, right?...
3)
Bill Moseley Yes, that's what I meant. I'm using transactions but to catch that you have to use serializable...
4)
Perrin Harkins If you actually want to prevent other people from deleting it, you probably want a SELECT...FOR...
spacer
View PostFlat  Thread  Threaded | Next >
Home > Groups > Class::DBI > [CDBI] Was it deleted? (4 posts) > View Post