Je vous propose l'optimisation suivante permettant d'allez à plus de 3 mots saisis dans le champs recherche.
Remplacer le code existant par celui-ci :
Code : Tout sélectionner
//initialize Session variables
if(!isset($_SESSION['user_id'])) $_SESSION['user_id'] = '';
//case when keywords contain '
$keywords = str_replace("'","\'",$keywords);
$tabSearch = explode(' ',$keywords);
$whereReq = "";
foreach ($tabSearch as $search) {
$whereReq .= $and." CONVERT(concat_ws(' ',tincidents.title,tincidents.description,tthreads.text,tsubcat.name,
tcategory.name,tincidents.id,tusers.firstname,tusers.lastname) USING UTF8) LIKE '%".$search."%'";
$and = "AND";
}
$from = "FROM tincidents
LEFT JOIN tcategory ON tincidents.category=tcategory.id
LEFT JOIN tsubcat ON tincidents.subcat=tsubcat.id
LEFT JOIN tstates ON tincidents.state=tstates.id
LEFT JOIN tthreads ON tincidents.id=tthreads.ticket
LEFT JOIN tusers ON tincidents.user=tusers.id
WHERE ".$whereReq."
AND tincidents.disable='0'
";