0

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?

1 Answer 1

5

From looking at your code, I expect this line needs to be corrected:

$this->db->where('id', $id); 

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.