Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

How to redo the save option in phalcon

this is my code ......

$user= new user();
$user->id=$this->request->getPost('id');
$user->name=$this->request->getPost('name');
$save=$user->save();
if($save==False){
$emp= new Employee();
$emp->is=$this->request->getPost('id');
$emp->name=$this->request->getPost('name');
$emp->mdn=$this->request->getPost('mdn');
$emp->save();
}

now sometimes i able to save the data in first table but not able to save the data in second table..in that case i want to redo the save option done in the first table.....how to that...as kept uniqueness validator in the first table if iam trying again its is saying that the data is already present as the data already saved in the table. Please help??



99.6k
Accepted
answer

Use transaction.

transction is not working when i am using alias below is my code.....

                $rel->setTransaction($transaction);
                $rel->emp_id = $user->id;
                $rel->wal_id = $this->request->getPost($type->wallettype_code);  
                $rel->pay_limit=$rel->limits->loading_limit;
                $rel->save();
                if($rel->save()==FALSE){
                $transction->rollback("Sorry");
                }

                but when i  am trying to save.....I got an error stating ::  trying to get a property of an non object....
                Please help