php - How to find fields by an array which contains multiple values by using like %% search -


i trying multiple fields match ids(1, 2, 3) %% search. have tried make work 2 hours, hasn't worked though looks pretty simple.

$ids = array ('1','2','3');  $result = $this -> model -> find ('all', array(     'conditions' => array( 'model.category like' => '%'.$ids.'%') )); 

i need somebody's help.

i'd suggest build 'conditions' array separately. example:

$ids = array ('1','2','3'); $conditions = array(); foreach($ids $id){     $conditions['or'][] = array( 'model.category like' => '%'.$id.'%') }  $result = $this->model->find('all', array('conditions'=>$conditions)); 

Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -