简体   繁体   中英

Not delete record from database in cakephp

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

 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());
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM