I am using codeigniter and i am using code like
$this->db->trans_start();
some 5 mysql inserts and
$this->db->trans_complete();
I am getting error like DB Transaction Failure
on 5th query i.e. some duplicate entry error. But still all my 1st 4 querys are executed. Should not it roll back ?
use "Strict Mode"
for your transaction. If will automatically roll back other query if one of the query fails. click here to see details. hope it will help you.
you could run transactions manually as follows:
$this->db->trans_begin();
$this->db->query('AN SQL QUERY...');
$this->db->query('ANOTHER QUERY...');
$this->db->query('AND YET ANOTHER QUERY...');
if ($this->db->trans_status() === FALSE)
{
$this->db->trans_rollback();
}
else
{
$this->db->trans_commit();
}