Mise à jour de search.php pour le soundex déplacé
authorx2000bedo <x2000bedo>
Sun, 15 Aug 2004 01:30:12 +0000 (01:30 +0000)
committerx2000bedo <x2000bedo>
Sun, 15 Aug 2004 01:30:12 +0000 (01:30 +0000)
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.

htdocs/search.php
include/search.classes.inc.php

index 9649bf6..04d1188 100644 (file)
@@ -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'),'');
index 134c947..e4086b6 100644 (file)
@@ -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;