Wednesday, January 25, 2012

using transactions in cake

hi everyone,

simple question :)
i have a controller function "save" where i save several data for
different models:

if(!empty($ToSave['Address']))
{

$this->User->UserAddress->save($this->data);
}

if(!empty($ToSave['UserTickets']))
{

$this->UserAdditionalInformation->save();

}

and some more saving here...


now I realized that I have no function to react on failed saving. I
read about transactions but I dont know how to apply that to my code.
Do I need to make a commit and rollback after each model saving or is
once enough?

And how can I give the user an ajax like feedback when saving failed?
i dont wanna redirect to a new page and rather show a message in a
popup..

thanks :)


--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: