Eg.:
if ($this->Utils->sendEmail($this->request->data['User']['email'], $this->request->data['User']['name'],$this->User->getLastInsertID() +1)) {
$this->User->create();
etc..
}
(maybe you will have to override the $this->Util->sendEmail function to return false if it failed, but that's easy)
-- On Mon, Nov 5, 2012 at 9:53 PM, Daniel <danwgrace@gmail.com> wrote:
I've got some of code that looks like:$this->User->create();
if ($this->User->save($this->request->data)) {
// ... do some other stuff$this->User->Profile->create();if $this->User->Profile->save($profile) {
if ($this->Utils->sendEmail($email_to, $username, $id)) {$this->Session->setFlash(__('The account has been created.'));
What I want to do is delete the user and profile records if the sendEmail fails, sort of like doing a manual transaction rollback.What I want to know is: is it neccessary to set the id before calling delete? e.g. do I need to use getLastInsertID() or will the value already be set:$this->User->delete();or:$this->User->id = $this->User->getLastInsertID();
$this->User->delete();Thanks.--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
No comments:
Post a Comment