我正在尝试使用 Cakedc 插件开发一个简单的搜索表单,我按照说明逐步进行操作,但我得到了下一个错误:
Database Error
错误: SQLSTATE[42000]: 语法错误或访问冲突: 1064 您的 SQL 语法有错误;请查看与您的 MySQL 服务器版本对应的手册,了解在第 1 行的"validateSearch"附近使用的正确语法
SQL 查询:验证搜索
我不知道我做错了什么,你能帮帮我吗?,这就是我得到的,谢谢。在控制器中:
class ProductosController extends AppController {
public $name = 'Productos';
public $uses = array('Empleado','Cliente', 'Mesa','Producto', 'Productotipo','Productos');
public $components = array('Search.Prg');
public $presetVars = true;
public $paginate=array();
public function ventas(){
$this->Prg->commonProcess();
$this->paginate['conditions'] = $this->Producto->parseCriteria($this->Prg->parsedParams());
$this->set('productos', $this->paginate());
}
在模型中:
class Producto extends AppModel {
public $name = 'Producto';
public $displayField = 'productotipos_id';
public $belongsTo = array('Productotipo'=>array('className'=>'Productotipo','foreignKey'=>'productotipos_id','conditions'=>'','order'=>''));
public $actsAs = array('Search.Searchable');
public $filterArgs = array(
'nombre' => array('type' => 'like')
);
在视图中
<?php echo $this->Form->create('Producto', array('url' => array_merge(array('action'=>'ventas'), $this->params['pass'])));?>
<fieldset>
<legend>Pedido</legend>
<?php
echo $this->Form->input('Producto.nombre', array('div'=>false, 'empty'=>true));
echo $this->Form->submit(__('Search', true), array('div' => false));
echo $this->Form->end();
?>
</fieldset>
尝试重新排序$uses
控制器的模型将是第一个:
public $uses = array('Producto', 'Empleado', 'Cliente', 'Mesa', 'Productotipo');
应该有帮助。不知道为什么,但可能 CakeDC 搜索插件中的一些方法取决于此数组中的第一项。
SQL 查询:验证搜索
是尝试调用不存在的模型方法时的常见错误。
因此,无论您尝试分页什么模型(不粘贴类声明不是一个好主意...)出于某种原因都不会使用可搜索的行为。
如果模型是正确的,则由于您必须弄清楚的某种原因,行为不会加载。