简体   繁体   中英

How can I implement LIKE, NOT IN, IN search functionality with CakePHP and MongoDB?

Currently I am using ichikaway cake-php MongoDB plugin to connect my CakePHP with MongoDB, I am facing an issues while executing find method, below is my code.

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

I get an empty response even though I have data in DB
Is there anything I am missing?
Thanks in advance

I think should be

$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
         ]);
      });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM