Answer the question
In order to leave comments, you need to log in
How to do a search by name?
Good afternoon.
I'm trying to search for a movie title in the database with the following SQL query:
// [name] => Проект засекречен / Проект «Синяя книга»
$connection->table('serials')
->where('name', 'LIKE', '%синяя книга%')
->get();
Answer the question
In order to leave comments, you need to log in
After half a day, I found a solution to the problem.
I made a custom function for converting a string to lowercase, since lower() refused to work with Cyrillic.
...
function mb_lower($str) {
return mb_strtolower($str);
}
// Если используется PDO:SQLite
$db->sqliteCreateFunction('mb_lower', 'mb_lower', 1);
// Если используется расшриение SQLite3
// $db->createFunction('mb_lower', 'mb_lower');
$sql = 'SELECT name, season, episode FROM serials WHERE mb_lower(name) LIKE mb_lower("%хОдЯчиЕе МеРТВЕЦЫ%")';
...
Could it be a case problem? Try a case-insensitive search and if it works, use the solution from the answer
https://stackoverflow.com/a/2876820
learn what % is in the query
then you will learn how to compose
'%blue%book%'
'blue%book%' - works faster
'blue%book%' etc.
with Karsluhe it is more difficult - this is done by fuzzy matching and synonyms in full-text search systems
and yes - in Muskul it is better to use www.mysql.ru/docs/man/Fulltext_Search.html
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question