如何使用CakePHP和MongoDB实现LIKE,NOT IN,搜索功能?

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

目前我正在使用ichikaway cake-php MongoDB插件将我的CakePHP与MongoDB连接,我在执行find方法时遇到问题,下面是我的代码。

debug($this->Keyword->find("all",array(
    "conditions" => array("Keyword.keyword LIKE"=>"%p%")
)));

即使我在DB中有数据,我也得到一个空的响应 有什么我想念的吗? 提前致谢

php mongodb cakephp cakephp-2.0
1个回答
0
投票

我认为应该是

$this->Keyword->find('all')
     ->where(function($event){return $event->or_([
          'Keyword.keyword LIKE '=>'%'.$this->request->query('search_item').'%',  // if search_item comes through GET method
         ]);
      });
© www.soinside.com 2019 - 2024. All rights reserved.