Answer the question
In order to leave comments, you need to log in
How to search the site?
Good afternoon! Tell me, is it possible to make a search on the site without using add. modules (sphinxsearch etc)?
There is a database with news, when I search for a resource (1 word) it finds it, but the name has more and, accordingly, does not find anything if you do not use the full name.
public function search ($querys) {
$querys = parent::obj()->connect()->quote($querys);
$news = "SELECT * FROM `news`
WHERE `title` LIKE $querys
OR `resource_name` LIKE $querys
OR `content` LIKE $querys";
$getnews = parent::obj()->connect()->query($news);
if(is_null($getnews)) {
return [];
}
return $getnews->fetchALL(PDO::FETCH_ASSOC);
}
Answer the question
In order to leave comments, you need to log in
and in general there is a more correct mechanism for this - full-text search. Mysql
LIKE searches without an index - you risk getting notable brakes.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question