我尝试进行搜索但最终出现错误:
在我的控制器中我写道:
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');
}
&GT;
答案 0 :(得分:0)
尝试使用cakeDC search-Plugin。它非常易于操作且非常灵活。 你只需要安装它。 配置非常简单。 https://github.com/CakeDC/search