Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cakephp condition with LIKE operator: how to handle multiple values

Tags:

cakephp-1.3

Hi I'm trying to do a condition like this:

array("Curriculum.name LIKE" => $array,"Curriculum.surname LIKE" => $array,)

But cakephp output is the following:

WHERE ((`Curriculum`.`name` LIKE IN ('%jon%','%x%')) OR (`Curriculum`.`surname` LIKE IN ('%jon%','%x%'))

Any idea in how to achieve this?

like image 361
capsula Avatar asked Dec 30 '11 03:12

capsula


1 Answers

foreach ($array as $name) {
    $conditions['or'][] = array('Curriculum.name LIKE' => "%$name%");
    $conditions['or'][] = array('Curriculum.surname LIKE' => "%$name%");
}
like image 171
deceze Avatar answered Oct 22 '22 19:10

deceze