Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Active Record Delete is not working properly

Tags:

php

I written a simple function to delete data from the database but the delete query is not properly my code for the model is as follows:

function removedata()
{
    $userid = $this->input->post('userid');
    $this->db->where('userid', $userid);
    $deldata = $this->db->delete('userbasic');
    if ($deldata == true) {
        echo "Data Removed Successfully";
    } else {
        echo "Deletion Failed";
    }
}

I have loaded the database already and tried both the query i.e.

 $this->db->where('userid',$userid);
  $deldata=$this->db->delete('userbasic');

and

$deldata=$this->db->delete('userbasic',array('userid'=>$userid));

So please suggest me answer there is no error in result it also prints data removed successfully but still data is not deleting from the database...

like image 225
Nilesh Mahajan Avatar asked Nov 13 '22 08:11

Nilesh Mahajan


1 Answers

the code seems fine. try to debug.

use this to print the query.

echo $this->db->last_query();

and then try execute that query in your phpmyadmin. and check weather it deletes your row.

like image 79
Dino Babu Avatar answered Nov 14 '22 22:11

Dino Babu