[eluser]neilmcgann[/eluser]
Hi Folks - first post :-)
I have been using the mysql pdo driver with no problems until I have tried to use transactions. Simply described, a failed transaction does not roll back all the statements.
If I switch the db config driver type to mysqli it works with no problem and rolls back perfectly.
This is a stripped down version of the code - it basically just deletes some stuff and then adds some new stuff, all wrapped in a transaction.
Code:
$this->CI->db->trans_start();
$this->CI->db->where('group_id',$group);
$this->CI->db->delete('users_groups_perms'); //delete a load of stuff to be replaced
$this->CI->db->insert_batch('users_groups_perms', $data); //deliberate error in $data to check rollback
$this->CI->db->trans_complete();
//do some stuff with $this->CI->db->trans_status()
I'm provoking a deliberate fail in the insert to check the rollback works - which it does in mysqli, but not in pdo. I've tried using trans_begin and manually doing the rollback/commit, but this doesn't work either. The trans_status function detects the error, so the driver knows something has gone wrong...but no rollback.
Anyone seen anything like this before?
Neil