CakeDC 搜索插件不起作用

问题描述 投票:0回答:2

我正在尝试使用 cakedc 插件开发一个简单的搜索表单,我一步步按照说明进行操作,但出现了下一个错误:

Database Error

错误:SQLSTATE[42000]:语法错误或访问冲突:1064 您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,了解在第 1 行“validateSearch”附近使用的正确语法

SQL 查询:validateSearch

我不知道我错了什么,你能帮我吗?,这就是我所得到的,谢谢。 在控制器中:

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>
php mysql cakephp cakedc
2个回答
3
投票

尝试重新排序

$uses
,控制器的模型将是第一个:

public $uses = array('Producto', 'Empleado', 'Cliente', 'Mesa', 'Productotipo');

应该有帮助。不知道为什么,但 CakeDC 搜索插件中的某些方法可能取决于此数组中的第一项。


0
投票

SQL 查询:validateSearch

这是当您尝试调用不存在的模型方法时常见的错误。

因此,无论您尝试分页什么模型(不粘贴类声明都不是一个好主意......),由于某种原因,都不会使用可搜索行为。

如果模型是正确的,则由于某种原因而未加载行为,您必须弄清楚。

© www.soinside.com 2019 - 2024. All rights reserved.