From: x2000bedo Date: Sun, 15 Aug 2004 01:30:12 +0000 (+0000) Subject: Mise à jour de search.php pour le soundex déplacé X-Git-Tag: xorg/old~1757 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=0400828b5d681bc24bef10839981296062fe1bcf;p=platal.git Mise à jour de search.php pour le soundex déplacé Je reprendrai demain pour le formulaire de recherche avancée et les tests sur le soundex car des scripts sont lancés sur jam en ce moment apparemment et le CPU ne me permet pas de travailler. --- diff --git a/htdocs/search.php b/htdocs/search.php index 9649bf6..04d1188 100644 --- a/htdocs/search.php +++ b/htdocs/search.php @@ -16,12 +16,14 @@ if (array_key_exists('rechercher', $_REQUEST)) { $with_soundex = ((isset($_REQUEST['with_soundex']) && $_REQUEST['with_soundex']==1)); if ($with_soundex) { - $nameField = new StringWithSoundexSField('name',array('s.nom_soundex','s.epouse_soundex','i.nom_soundex'),''); - $firstnameField = new StringWithSoundexSField('firstname',array('s.prenom_soundex','i.prenom_soundex'),''); + $nameField = new + StringWithSoundexSField('name',array('s.nom_soundex','s.epouse_soundex','i.nom_soundex'),'r.nom1'); + $firstnameField = new + StringWithSoundexSField('firstname',array('s.prenom_soundex','i.prenom_soundex'),'r.prenom1'); } else { - $nameField = new StringSField('name',array('r.nom1','r.nom2','r.nom3'),''); - $firstnameField = new StringSField('firstname',array('r.prenom1','r.prenom2'),''); + $nameField = new StringSField('name',array('r.nom1','r.nom2','r.nom3'),'r.nom1'); + $firstnameField = new StringSField('firstname',array('r.prenom1','r.prenom2'),'r.prenom1'); $with_soundex = ($nameField->length()==0 && $firstnameField->length()==0)?(-1):0; } $promo1Field = new PromoSField('promo1','egal1',array('r.promo'),''); diff --git a/include/search.classes.inc.php b/include/search.classes.inc.php index 134c947..e4086b6 100644 --- a/include/search.classes.inc.php +++ b/include/search.classes.inc.php @@ -125,12 +125,12 @@ class StringSField extends SField { //Nouvelle version plus rapide $regexp = str_replace('-',' ',$this->value); $regexp = str_replace('*','%',$regexp); - return $field." LIKE LCASE($regexp%)"; + return $field." LIKE LCASE('$regexp%')"; } /** clause ORDER BY correspondant à ce champ de formulaire */ function get_order_statement() { - if ($this->value!='') + if ($this->value!='' && $this->fieldResultName!='') return $this->fieldResultName.'!="'.$this->value.'"'; else return false;