0

我尝试进行搜索,但最终出现错误:

在我的控制器中,我写道:

public function search() {
  $this->set('results',$this->History->search($this->data['History']['searchtext']));
}

在我看来,我写道:

//#查看/历史/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');
}

?>

4

1 回答 1

0

试试 cakeDC 搜索插件。它非常易于处理且非常灵活。你只需要安装它。配置非常简单。 https://github.com/CakeDC/search

于 2013-03-04T08:34:11.333 回答