I'm modifying code in dolibarr and i went through a problem with the search in desciption of products with WYSIG editor (recording html text). The search of description containing several words doesn't work after a
(maybe all tags) or at the very start of text, the first word does not return the description. Plus, "galvanisé" works with the "é" but not "d'options" with quote. see examples below :
I tried to use htmlentities and to include end or start of tags (see below).
the description :
Filtre standard avec tout un tas d'options 900x400x116
Nom 22
EN779-2002
acier galvanisé
for( $i=0 ; $i < sizeof($tabMots) ; $i++) {
if($i == 0) {
if(is_numeric($tabMots[$i]))
$sql.= ' WHERE (p.description LIKE \'% '.$tabMots[0].' %\' OR p.description LIKE \'%>'.$tabMots[0].' %\' OR p.description LIKE \'%>'.$tabMots[0].'<%\' OR p.description LIKE \'% '.$tabMots[0].'<%\' )';
else
$sql.= ' WHERE (p.description LIKE \'% '.$tabMots[0].'%\' OR p.description LIKE \'% '.htmlentities($tabMots[0]).'%\' OR p.description LIKE \'%>'.$tabMots[0].'%\' OR p.description LIKE \'%>'.htmlentities($tabMots[0]).'%\' )';
} else {
if(is_numeric($tabMots[$i])) {
$sql.= ' AND (p.description LIKE \'% '.$tabMots[$i].' %\' OR p.description LIKE \'%>'.$tabMots[$i].'%\' OR p.description LIKE \'%>'.$tabMots[$i].' %\' OR p.description LIKE \'%>'.$tabMots[$i].'<%\' OR p.description LIKE \'% '.$tabMots[$i].'<%\' )';
} else {
$sql.= ' AND (p.description LIKE \'% '.$tabMots[$i].'%\' OR p.description LIKE \'% '.htmlentities($tabMots[$i]).'%\' OR p.description LIKE \'%>'.$tabMots[$i].'%\' OR p.description LIKE \'%>'.htmlentities($tabMots[$i]).'%\' )';
}
}
}
I would like to avoid to add a plain text field in order to not modify the dolibarr database. Thanks.
EDIT : The proposed Answer is no good because the problem is the text format HTML of the text description not criterias of search.