Grokbase
Topics Posts Groups | in
x
[ help ]

Re: [CDBI] Re: Was it deleted?

View PostFlat  Thread  Threaded | < Prev - Next >
Bill Moseley Re: [CDBI] Re: Was it deleted?
| +1 vote
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
On Thu, Sep 21, 2006 at 03:41:31PM -0400, Edward J. Sabol wrote:
> Bill Moseley asked:
> > Shouldn't this check the row count?
>
> You mean the number of rows affected by the SQL delete statement, right?
> Anyway, no, I don't think it should really, but that's just my opinion. You
> might want to look into using transactions if you're worried about another
> process deleting records that you're using....

Yes, that's what I meant.  I'm using transactions but to catch that
you have to use serializable transactions and re-read the objects once
inside the transaction.  Then all that fails when using "nested"
transaction since you can't change the isolation level once a select
has been done inside a transaction.

Of course, even if CDBI did check the row count there's the issue of
what to do with the triggers if no rows are updated.

Still, might be handy to do this (well, as an eample):

    DB->do_transaction( sub {

        DB::History->add("$user deleted $thing");

        $thing->ledger->credit( $thing->cost );

        $thing->delete || die "Failed to delete";
    });

I've overridden delete so I can do this.


--
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 | < Prev - Next >
Home > Groups > Class::DBI > [CDBI] Was it deleted? (4 posts) > View Post