开发者

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜