1

I have a simple query to delete record from mysql database.

Here is my query:

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

return $result;

This is what I'm getting:

A Database Error Occurred Error Number: 1054

Unknown column '108' in 'where clause' DELETE FROM tbl_post WHERE post_Id = '108' AND 108 IS NULL

Filename: C:\xampp\htdocs\socialsite\system\database\DB_driver.php

Line Number: 330

2 Answers2

0

Try this one,it will help and there is no need to return something.

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');
}
Raham
  • 4,781
  • 3
  • 24
  • 27
0

Fixed the bug In this code there are 2 values passing to delete. So removing $post_Id in $result will work.

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

Updated code:

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