I've got some of code that looks like:
$this->User->create();
if ($this->User->save($this->request->data)) {
// ... do some other stuff
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)) {
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();
$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.
No comments:
Post a Comment