方法一
//=====================================
// models
//=====================================
public function delete($id){
$this->db->delete('news', array('id' => $id));
//產生: DELETE FROM news WHERE id = $id
}
//=====================================
// models
//=====================================
public function delete($id){
$this->db->where('id', $id);
$this->db->delete('mytable');
}
方法二
//=====================================
// Controller
//=====================================
public function delete()
{
//id
$class_item_id = (int)$this->input->get('class_item_id', TRUE);
$sql = "delete from class_item where class_item_id=".$class_item_id;
//執行model
$this->sql_class_item->del($sql);
redirect('manage/class_item');
}
//=====================================
// models
//=====================================
//刪除
public function del($data){
$this->db->query($data);
}
沒有留言:
張貼留言