Welcome Guest, Not a member yet? Register   Sign In
Transactions
#1

Hello, i would like to run some sql statements but, if there is any exception (not only Database Exception, but any exception like out of memory etc) i want the sql statements rolled back. 
I have a mysql database with all the tables on INNODB engine.
I made this code:

PHP Code:
$db = \Config\Database::connect();
 
$db->transBegin();

try { 
    $rc $model->execute(array($structure_id));
    $db->transCommit();
}
catch (\
Exception $e)
{
    $db->transRollback();
    log_message('debug''Exception: ' $e->getMessage());


In the function execute I am throwing an exception but the sql is commited and not rolled back. What am I doing wrong?

Thanks
Reply




Theme © iAndrew 2016 - Forum software by © MyBB