2017-05-04 61 views
0

我還是CodeIgniter的新手。我試圖找出如何從我的表中刪除行。因爲當我使用這個函數時,我可以刪除我的行。 有沒有人知道這個解決方案?以及如何刪除成功與否,我如何獲得狀態?如何通過刪除模型中的行來獲取狀態

public function deleteEpass($serial) 
    { 
     $this->db->trans_start(); 
     $this -> db -> where('serial', $serial); 
     $this -> db -> delete('epass'); 
     $this->db->trans_complete(); 
     return $this->db->trans_status(); 
    } 

回答

0

affected_rows()應返回受影響的行數。所以你可以使用這個。

$this -> db -> where('serial', $serial); 
 
     $this -> db -> delete('epass'); 
 
     return $this->db->affected_rows();

0
$this->db->trans_begin(); 
$this->db->where('serial', $serial); 
$this->db->delete('epass'); 
if (($this->db->trans_status() === FALSE)) { 
$this->db->trans_rollback(); 
return FALSE; 
} else { 
$this->db->trans_commit(); 
return $this->db->affected_rows(); 
} 
相關問題