簡體   English   中英

刪除記錄時where子句codeigniter中的未知列

[英]unknown column in where clause codeigniter when deleting record

我有一個簡單的查詢,可從mysql數據庫中刪除記錄。

這是我的查詢:

$this->db->where('post_Id', $post_Id);
$result = $this->db->delete($this->mastables['post'],$post_Id);

return $result;

這就是我得到的:

發生數據庫錯誤,錯誤號:1054

'where子句'中的未知列'108'從tbl_post刪除WHERE post_Id ='108'並且108 NULL

文件名:C:\\ xampp \\ htdocs \\ socialsite \\ system \\ database \\ DB_driver.php

行號:330

試試這個,它會有所幫助,不需要返回任何東西。

function delete($your_id)
{
    $this->db->where('your_tb_id',$your_id); //your_tb_id is key field in your table
    $this->db->delete('table_name');
}

修復了此代碼中的錯誤,其中傳遞了兩個要刪除的值。 因此,在$ result中刪除$ post_Id將起作用。

$this->db->where('post_Id', $post_Id);
$result = $this->db->delete($this->mastables['post'],$post_Id);

更新的代碼:

$this->db->where('post_Id', $post_Id);
$result = $this->db->delete($this->mastables['post']);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM