2011-05-31 84 views
0

如何判断事务是否为FALSE或者是否发生了其他事情(锁定表)?CodeIgniter:事务错误与MySQL错误

$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; 

例如,由于外键约束,事务可能失败。如果是这种情况,我会运行另一个查询。在任何其他情况下,我想重试原始查询。

回答

-1

检查查询是succesfull

if($q) 
echo ok 
else 
echo ko