cakephp condition with LIKE operator: how to handle multiple values

12,128
foreach ($array as $name) {
    $conditions['or'][] = array('Curriculum.name LIKE' => "%$name%");
    $conditions['or'][] = array('Curriculum.surname LIKE' => "%$name%");
}
Share:
12,128
capsula
Author by

capsula

Updated on August 05, 2022

Comments

  • capsula
    capsula over 1 year

    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?

  • whitesiroi
    whitesiroi almost 8 years
    Thank you very much for the question and for the awesome answer. Did help a lot :)