1

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

“注意(8):间接修改重载属性 SearchesController::$paginate 无效 [APP/Controller/SearchesController.php, line 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());
    }
}

使用烘焙创建的任何索引的视图都是相同的。知道我的错误是什么吗?谢谢大家!!

S。

4

2 回答 2

1

如果你这样做,你需要先在你的控制器中声明分页:

public $paginate = array();

或直接在您的方法中初始化它

 $this->paginate = array();
于 2012-09-25T08:58:48.030 回答
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));
  }
}
于 2012-09-25T08:59:04.763 回答