不从cakephp中删除数据库中的记录
我的删除记录查询。
public function del_mail($mailid)
{
$this->Mymail->deleteAll(array('mailid'=>$mailid));
$this->Session->setFlash(__('Delete Successful', true), 'default');
$this->redirect($this->referer());
}
错误。
错误:SQLSTATE [42S22]:找不到列:1054未知列' Mymail.id'在'字段列表'
SQL查询:SELECT DISTINCT`Mymail``id` FROM`babysoft_storel` .mymails` AS`Mymail` WHERE`mailid` = 1
答案 0 :(得分:0)
Error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'Mymail.id' in 'field list'
你有一个mysql查询错误,你确定你有' Mymail.id'在你的表格字段中?
根据您的评论,请试试这个:
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());
}