I have this code inside my search model:
$query->andFilterWhere(['like', 'name', $this->name])
It generates LIKE '%name% , which is fine in most ocasions.
But I would like my system to be able to replace spaces by %, so I could search for "Homer Simpson" and the system would include "Homer J Simpson" in the result.
How do I set the like operator? I’ve tried to replace spaces by % inside the searched name without success.
Many views but no answer…
This question must be too hard, or too easy to deserve an answer!
Anyway, if someone has the same problem… I already figured it out.
$query->andWhere('name like '.$search_name)
As far as I was able to understand, you can’t use andFilterWhere to do this.
But within andWhere you can build your WHERE clause just like in SQL.