Friday, January 15, 2016

Help me abount transaction (begin, commit, rollback) in cakephp 3 version

Hi,

I am coded from ref link - http://book.cakephp.org/3.0/en/orm/database-basics.html#using-transactions.
But my code is running perfectly. But data is not updated or inserted into database.

Below is my code (controller) -

$conn = ConnectionManager::get('default');

$conn->begin();
try {
   
    // here is my code //

    $conn->commit();
} catch(Exception $e) {
    // do exception handling
    $conn->rollback();
}       


When I used exit before commit line the database is updated and as well as insert values. But when the exit remove the rollback is working (I think).

Please help or guide me.

--
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 unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at https://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: