我在找出我从哪里得到这个错误时遇到了一些麻烦:
错误:SQLSTATE [42S22]:找不到列:1054 'where 子句'中的未知列'dummy@.books.id'
sql查询
UPDATE
`dummy@`.`books`
SET
`isbn` = '1234532',
`title` = 'cakephp blog tutorial',
`id` = 5,
`description` = 'gh',
`author_name` = 'andrew'
WHERE
`dummy@.books.id` = '5'
如果我编辑记录,则会发生以下错误
控制器功能
function edit ($id = NULL){
if (!$id && empty($this->request->data)) {
$this->Session->setFlash('Invalid Book', true);
$this->redirect(array('action'=>'index'));
}
else {
$this->Book->create();
$save = $this->Book->save($this->request->data);
if($save){
$this->Session->setFlash('book detail edit successfully');
$this->redirect(array('action'=>'index',$id));
}
}
if(empty($this->request->data)){
$this->request->data = $this->Book->read(NULL,$id);
}
}
并查看ctp文件
<?php echo $this->Form->create('Book');?>
<fieldset>
<legend> Edit New Book </legend>
<?php
echo $this->Form->input('isbn');
echo $this->Form->input('title');
echo $this->Form->hidden('id');
echo $this->Form->input('description');
echo $this->Form->input('author_name');
?>
</fieldset>
<?php echo $this->Form->end('Edit Book');?>