I have a function written to delete entries from a table called stack. I have written similar function for other tables and it works. For this its not working, but no errors too. How can I find out whats wrong?
Controller entry:
function delete_tag($id)
{
$this->Mrestaurant->delete_tag($id);
echo 'deleted!';
}
Model Entry:
function delete_tag($id)
{
$this->db->where('id', '$id');
$this->db->delete('stack');
}
Database and all i have preloaded:
$this->load->database();
$this->load->model('Mdb','',TRUE);
Every other db functions are working like adding, updating, deleting other datas etc… I’m confused because there is no error. And I don’t know how to find out whats wrong.
Update
This worked in model
$this->db->delete('stack', array('id' => $id));
Any idea why?
From looking at your code, I expect this line needs to be corrected:
Notice that there are no single quotes (or any quotes) around
$id. Your second example worked, because it is an alternative to your first, except this time you didn’t use single quotes by accident.