0
votes

Not delete record from database in cakephp

my query for delete record.

public function del_mail($mailid)
    {
        $this->Mymail->deleteAll(array('mailid'=>$mailid));
        $this->Session->setFlash(__('Delete Successful', true), 'default');
        $this->redirect($this->referer());
    }

Error.

Error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'Mymail.id' in 'field list'

SQL Query: SELECT DISTINCT `Mymail`.`id` FROM `babysoft_storel`.`mymails` AS `Mymail` WHERE `mailid` = 1

1

1 Answers

0
votes
 Error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'Mymail.id' in 'field list'

You have an error of mysql query and are you sure you have the 'Mymail.id' in your table field?

According to your comment below Please try this :

public function del_mail($mailid)
    {
        $this->Mymail->deleteAll(array('Model.mailid'=>$mailid)); //where Model is your Model you used to retrieving the mailid field.
        $this->Session->setFlash(__('Delete Successful', true), 'default');
        $this->redirect($this->referer());
    }