2012-10-02 45 views
0

我使用插件cakedc搜索,但有一件事我似乎无法找到,我有一个窗体有两个字段,我会添加例如“online = 1”到我的搜索 在我的控制,我想:cakedc搜索插件使用pb

public function find() { 
$this->Prg->commonProcess(); 
$array = array('type'=>'post', 'online'=>'1', 'created'=> '<= NOW()'); 
$this->passedArgs = Set::merge($this->passedArgs, $array); 

    $this->paginate = array(
     'conditions' => array($this->Post->parseCriteria($this->passedArgs)), 
    ); 
    $this->set('posts', $this->paginate()); 

型号:

public $displayField = array('name', 'category_id'); 

    public $filterArgs = array(
       array('name' => 'name', 'type' => 'query', 'method' => 'filterName'), 
       array('name' => 'category_id', 'type' => 'value') 
      ); 
..... 

调试($这个 - > passedArgs):

array(
    'name' => 'mon', 
    'category_id' => '2', 
    'type' => 'post', 
    'online' => '1', 
    'created' => '<= NOW()' 
) 

但$ array参数不会在我的搜索中被采用 任何人都可以帮忙吗? 我是一个初学者与cakephp, 非常感谢!

+0

请参阅http://chetan4cake.blogspot.in/2012/06/search-plugin-demo-in-cakephp-20.html – chetanspeed511987

回答

0

而不是

'conditions' => array($this->Post->parseCriteria($this->passedArgs)), 

尝试

'conditions' => $this->Post->parseCriteria($this->passedArgs), 

我也建议你使用DebugKit和生成的查询添加到你的问题现在还没有工作的情况。