I'm trying to build an array to retrieve data from my database using cakephp according to a search value. but I've found an strange behavior. The % literal removes the first two character of any string/integer if its a number.
I'm trying to search everything like %250% then cake or php outputs 0%. it removes the % and 25. This doesn't happen if the $filter is not a number.
This is my code.
if(in_array('part', $s)){
array_push($conditions, array("PN_CLEAN" => $aux));
array_push($conditions['OR'], array("PN_CLEAN LIKE" => '%'.trim($filter).'%'));
}
if(in_array('brand', $s)){
array_push($conditions['OR'], array("BRAND_FOR_INVENTORY LIKE" => '%'.trim($filter).'%'));
}
if(in_array('desc', $s)){
array_push($conditions['OR'], array("DESCRIPTION_FOR_INVENTORY LIKE" => '%'.trim($filter).'%'));
}
if(in_array('cat', $s)){
array_push($conditions['OR'], array("CATEGORY_FOR_INVENTORY LIKE" => '%'.trim($filter).'%'));
}
I've tried casting, sprintf, strval and nothing works.
Thanks