i have problem when executed this code in CodeIgniter it deletes all records not only the max value record although it works fine if i execute Sql query in phpmyadmin what wrong in PHP code
my code:
controller:
$this->data->del_data_query('DELETE FROM `sessions` WHERE
sessions.name =
"dina" and id = (select max(id) from `sessions` ) ');
Model:
public function del_data_query($query)
{
$this->db->query($query);
}
2
Answers
This should do the trick. Also make sure that your id column is index = UNIQUE and is intiger
The query is correct: i tried it on my db.
Are you sure that, for some reason, your php didn’t call del_data_query more than one times?
You could use some debug to test it, or more easily, add
echo 'DONE';
on end of method