0
我尝试做一个搜索,但我最终错误:语法错误或访问违反了简单的搜索
在我的控制器我写道:
public function search() {
$this->set('results',$this->History->search($this->data['History']['searchtext']));
}
在我的观点我写道:
//#View/Histories/searchall.ctp
<?php
echo $this->Form->create("History",array('action' => 'search'));
echo $this->Form->input("searchtext", array('label' => 'Search for'));
echo $this->Form->end("Search");
?>
,并返回
"Error: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'search' at line 1" in my search.ctp
在我的历史模型
我写道:
<?php
class History extends AppModel{
var $name='History';
var $actsAs=array('Searchable');
}
>
你的'History'模型中有'search'方法吗? – dhofstet 2013-03-04 05:53:52
此外,您展示了'searchall'的视图,但您* Controller中的操作称为“搜索”。 – thaJeztah 2013-03-04 08:33:42