Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
cakephp插件搜索cakeDC用法_Cakephp_Search_Plugins_Cakedc - Fatal编程技术网

cakephp插件搜索cakeDC用法

cakephp插件搜索cakeDC用法,cakephp,search,plugins,cakedc,Cakephp,Search,Plugins,Cakedc,我正在使用cakeDC提供的cakephp搜索插件的2.0版本(使用cakephp 2.x)(https://github.com/CakeDC/search) . 我需要在许多模型中搜索,但这些模型并不相关。因此,我创建了一个新模型(搜索)和一个控制器(搜索)。我犯了这个错误 “注意(8):间接修改重载属性SearchesController::$paginate无效[APP/Controller/SearchesController.php,第17行]” 型号: App::uses('App

我正在使用cakeDC提供的cakephp搜索插件的2.0版本(使用cakephp 2.x)(https://github.com/CakeDC/search) . 我需要在许多模型中搜索,但这些模型并不相关。因此,我创建了一个新模型(搜索)和一个控制器(搜索)。我犯了这个错误

“注意(8):间接修改重载属性SearchesController::$paginate无效[APP/Controller/SearchesController.php,第17行]”

型号:

App::uses('AppModel', 'Model');
class Search extends AppModel {
    public $actsAs = array('Search.Searchable');
    public $useTable = false;
    public $filterArgs = array(
        'terminada' => array(
            'type' => 'like',
            'field' => array(
                'Sludge.terminada',
                'SurfacesWater.terminada',
                'ResidualWater.termianda',
                'UndergroundWater.terminada',
                'PotableWater.terminada',
                'SpecifiedsResidualsWater.terminada'
            )
        ),
        'revisada' => array(
            'type' => 'like',
            'field' => array(
                'Sludge.revisada',
                'SurfacesWater.revisada',
                'ResidualWater.revisada',
                'UndergroundWater.revisada',
                'PotableWater.revisada',
                'SpecifiedsResidualsWater.revisada'
            )
        ),
        'eliminada' => array(
            'type' => 'like',
            'field' => array(
                'Sludge.eliminada',
                'SurfacesWater.eliminada',
                'ResidualWater.eliminada',
                'UndergroundWater.eliminada',
                'PotableWater.eliminada',
                'SpecifiedsResidualsWater.eliminada'
            )
        ),
    );
    public function orConditionsDates($data = array()) {
        $start = date('Y-m-d');
        $end = date('Y-m-d', strtotime('-1 month'));
        $cond = array(
            'OR' => array(
                $this->alias . '.monitoreofecha LIKE <=' => $end,
                $this->alias . '.monitoreofecha LIKE >=' => $start,
                ));

        return $cond;
    }
}
该视图与使用烘焙生成的任何索引相同 知道我的错误是什么吗? 谢谢大家


S.

如果以这种方式执行,则需要首先在控制器中声明分页:

App::uses('AppController', 'Controller');
class SearchesController extends AppController {
    public $components = array('Search.Prg');
    public $presetVars = true; // using the model configuration
    public function index() {
        $this->Prg->commonProcess();
        $this->paginate['conditions'] = $this->Search->parseCriteria($this->passedArgs);
        $this->set('searches', $this->paginate());
    }
}
public $paginate = array();
或者直接在方法中初始化它

 $this->paginate = array();

如果这样做,则需要首先在控制器中声明paginate:

App::uses('AppController', 'Controller');
class SearchesController extends AppController {
    public $components = array('Search.Prg');
    public $presetVars = true; // using the model configuration
    public function index() {
        $this->Prg->commonProcess();
        $this->paginate['conditions'] = $this->Search->parseCriteria($this->passedArgs);
        $this->set('searches', $this->paginate());
    }
}
public $paginate = array();
或者直接在方法中初始化它

 $this->paginate = array();
试着这样做: App::使用('AppController','Controller')

试着这样做: App::使用('AppController','Controller')


现在我有很多警告,array_keys()希望参数1是array,null[CORE/Cake/Model/Datasource/DboSource.php,第2296行]问题是$this->Search->parseCriteria($this->passedArgs);返回一个空数组。你试过我当前的头了吗?我想我已经解决了一些问题。PS:这里的值正好是NULL,而不是数组。这是问题的根源。某些方法返回NotArray for empty。如果你能帮我找到那个方法,我可以帮你修好它。到目前为止,我从未遇到过这个问题。mark我有相同的结果pr($cond),结果是Array()。菜单中还有其他错误“array_keys()期望参数1是数组,如果[CORE/Cake/Model/Datasource/DboSource.php,第2296行]为空”。这就是问题所在,因为我的模型没有表,我正在尝试从其他模块获取结果。是的,您需要在分页数组中使用contain:
$This->paginate['contain']=array(…)
,并且不要忘记包含必要的模型。现在我有很多警告array\u keys()希望参数1是array,null给定[CORE/Cake/Model/Datasource/DboSource.php,第2296行]问题是$this->Search->parseCriteria($this->passedArgs);返回一个空数组。你试过我当前的头了吗?我想我已经解决了一些问题。PS:这里的值正好是NULL,而不是数组。这是问题的根源。某些方法返回NotArray for empty。如果你能帮我找到那个方法,我可以帮你修好它。到目前为止,我从未遇到过这个问题。mark我有相同的结果pr($cond),结果是Array()。菜单中还有其他错误“array_keys()期望参数1是数组,如果[CORE/Cake/Model/Datasource/DboSource.php,第2296行]为空”。这就是问题所在,因为我的模型没有表,我正在尝试从其他模块获取结果。是的,您需要在分页数组中使用contain:
$This->paginate['contain']=array(…)
,并且不要忘记包含必要的模型。