我正在使用cakeDC的cakephp搜索插件的2.0版本(使用cakephp 2.x)(https://github.com/CakeDC/search)。我需要在许多模型中进行搜索,但这些模型并不相关。所以我创建了一个新模型(搜索)和一个控制器(搜索)。我收到了这个错误
“Notice(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;
}
}
控制器:
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());
}
}
该视图与使用bake制作的任何索引相同 知道我的错误是什么? 谢谢大家!!
S上。
答案 0 :(得分:1)
如果你这样做,你需要先在控制器中声明paginate:
public $paginate = array();
或直接在您的方法中初始化
$this->paginate = array();
答案 1 :(得分:0)
尝试这样做: App :: uses('AppController','Controller');
class SearchesController extends AppController {
public $components = array('Search.Prg');
public $presetVars = true; // using the model configuration
public $paginate = array();
public function index() {
$this->Prg->commonProcess();
$cond = $this->Search->parseCriteria($this->passedArgs);
$this->set('searches', $this->paginate('Search', $cond));
}
}