CodeIgniter : Transaction ERROR vs MySQL ERROR
How can I tell if the transaction was FALSE or if something else happened(locked table)?
$this->db->trans_start();
$this->db->where('id', $id)
->limit(1);
$q = $this->db->delete('table');
$this->db->trans_complete();
return $this->db->trans_status() ? TRUE : FALSE;
For example, the transaction might fail because of a foreign开发者_开发问答 key constraint. If that is the case I would run another query. In any other case I want to retry the original query.
Check if the query was succesfull
if($q)
echo ok
else
echo ko
精彩评论