Answer the question
In order to leave comments, you need to log in
How to make a search not by the exact occurrence of the search word?
Hello! I know that in yii2 it's better to use the sphynx library to search the site, but now I'm doing it manually with the following request:
$query = Pages::find()->where(['like', 'title', $q]);
$sql = "SELECT title FROM pages WHERE title LIKE '%" . $q . "%' ";
Answer the question
In order to leave comments, you need to log in
If you did it through the GRUD generator in gii, then you should have created a certain NameSearch class.
Connect to it in any way convenient for you, I used the DetailView and ListView widgets. In principle, skillfully, you can display information in any form. A minimum of code, numbering, pagination, recalculation of the number of displayed records, you can form the appearance as you want, such moments are already provided in the search class. I don’t know about others, for any coincidence I displayed infa, even one character at a time, at least 3 characters, it doesn’t matter)))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question