我有一个简单的查询来从mysql数据库中删除记录。
这是我的问题:
$this->db->where('post_Id', $post_Id);
$result = $this->db->delete($this->mastables['post'],$post_Id);
return $result;
这就是我得到的:
发生数据库错误错误编号:1054
未知列"where clause"中的"108"DELETE FROM
tbl_post
wherepost_Id
="108"和108
为空文件名:C: ''examplep''htdocs''socialsite''system''database''DB_driver.php
Line编号: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');
}
修复了错误在这段代码中,有两个值被传递给delete。因此,在$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']);