2012-08-30 51 views
0

,這並不多行似乎工作:刪除在SQL /笨

/// delete emails first 
     $this->db->where('DateSent', 'DateSent!=NULL'); 
     $this->db->delete('Emails'); 

我想我需要使用一個循環。不知道如何去做這件事。誰能幫忙?

乾杯

回答

4

如果你看重的是非常有用的CodeIgniter userguide你會看到操作員應包括第一個參數的一部分不是第二個。這應該解決這個問題:

$this->db->where('DateSent !=', 'NULL'); 
$this->db->delete('Emails'); 
+0

沒有工作:發生數據庫錯誤 錯誤Nu mber: '='附近的語法不正確。 DELETE FROM Emails WHERE DateSent!= – thejoker

+0

對不起,有一個錯字...我已經更新它包括單引號NULL –

0

首先,你需要選擇的值存儲到一個數組說「$檢查」

$checked = implode(',',$checked);  //then it looks array('id1','id2','id3',..); 

,那麼你可以刪除作爲

$this->db->where("iUserId in",$checked); 

$this->db->delete('my_table'); 

就是這樣。它適用於我。我希望它適用於you.accept如果它的有用