[CDBI] Committing on delete

Matt S Trout dbix-class at trout.me.uk
Thu Apr 27 13:59:26 BST 2006


Nick Peters wrote:
> Hi,  I'm sorry about having to ask such a basic question.
> 
> I'm trying to add transactions to my database.  I have been able to 
> commit insertions and edit records but I really can't work out how to 
> commit deletions.
> 
> Trying update or dbi_commit  on the object I have just deleted gives me 
> the error "Can't locate object method "x" via package 
> "Class::DBI::Object::Has::Been::Deleted" which I can understand as I'm 
> trying to call it on an object I have just deleted but I can't work out 
> how I am meant to commit the change.

Right. Class::DBI can't deal with objects not in the database so it re-blesses 
deleted objects into that dummy class (as opposed to DBIx::Class' approach of 
clearing an ->in_storage flag on the object, which has a different set of 
tradeoffs attached).

Best bet would be to grab the class of the object immediately before you 
delete it and then calling dbi_commit on the class; since CDBI handles 
connection info as classdata that should work just fine.

-- 
      Matt S Trout       Offering custom development, consultancy and support
   Technical Director    contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

+ Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +




More information about the ClassDBI mailing list