 | | Offres d'emplois |  | Formateur confirmé PHP5/MySQL Ip-formation, école d'informatique depuis 13 ans, recherche un formateur confirmé en PHP5 / MySQL.
Missions principales :
- Assurer les cours... | |
 | | Avez vous lu ? |  | | |
|
 Une fonction pour générer la clause match | |  |

<?php
function clause_match($champs, $motcles, $operateur='or',
$lg_mini=3, $query_expansion=0) {
// --- éclatement des mots clés en tableau
$tb = explode(' ', $motcles);
// --- traitement des mots clés
$tb2 = array();
for ($i=0; $i<count($tb); $i++) {
$mot = $tb[$i];
if (strlen($mot) >= $lg_mini) {
if (strtolower($operateur) == 'and') $mot = '+' . $mot;
$tb2[] = $mot;
}
}
// --- composition de la clause
$txt_against = '';
for ($i=0; $i<count($tb2); $i++) {
if ($i > 0) $txt_against .= ' ';
$txt_against .= $tb2[$i];
}
if (strtolower($operateur) == 'and') $txt_boolean = 'in boolean mode';
else $txt_boolean = '';
if ($query_expansion) $txt_expansion = 'with query expansion';
else $txt_expansion = '';
$clause = "match ($champs)
against('$txt_against' $txt_boolean $txt_expansion)";
return($clause);
}
?>
|
|
|
 |
|