MAJ Sphinx allégé

This commit is contained in:
Michael RICOIS 2011-11-16 14:57:23 +00:00
parent 5208c398f9
commit 85ebd85a84
2 changed files with 22 additions and 17 deletions

View File

@ -10,11 +10,13 @@
*/
Class SDmotor
{
protected $sphinx;
protected $formR;
protected $index;
protected $debug = true;
/** Critères pour sphinx **/
protected $criteresLetters;
protected $Crtiteres = array('raisonSociale' => '',
'Voie' => '@addresse',
'cpVille' => '@ville',
@ -140,8 +142,7 @@ Class SDmotor
'Durée exécution :' => $total_time,
'Erreure :' => 'Le formulaire est Vide !')
);
/*$this->filtreCaracteresSpeciaux();*/
$this->sphinx->SetSortMode($this->setSortMode(SPH_MATCH_EXTENDED2), "@weight rang");
$this->sphinx->SetSortMode(SPH_MATCH_EXTENDED, "sirenValide DESC, rang DESC, actif DESC, siege DESC");
$this->sphinx->SetLimits(intval($this->deb), intval($this->nbRep), intval($this->max));
$this->maxSizeWord = 0;
switch($this->formR['SPH_MATCH']) {
@ -202,8 +203,7 @@ Class SDmotor
*/
public function SPH_MATCH_($type)
{
global $link, $sequence, $wordformRS, $adrRef;
require_once realpath(dirname(__FILE__)) . '/sequence.php';
include 'sequence.php';
if($this->debug) $html = '';
$ref = array('acrony', 'normal', 'points', 'split', 'space', 'double', 'quorum');
@ -217,6 +217,7 @@ Class SDmotor
print_r($this->formR);
foreach($link[$valeur]['id'] as $seqId) {
if($this->debug) $html .= '<br /><b>Séquence :</b> '.$sequence[$link[$valeur]['id'][$i]].'<br />';
$this->criteresLetters = $sequence[$link[$valeur]['id'][$i]];
$tab = explode('.', $sequence[$link[$valeur]['id'][$i]]);
if(in_array('S', $tab)) {
$nb = 1;
@ -345,8 +346,7 @@ Class SDmotor
**/
public function formatRaisonSociale($rs, $double = false)
{
global $link, $sequence, $wordformRS, $adrRef;
require_once realpath(dirname(__FILE__)) . '/sequence.php';
include 'sequence.php';
if(!empty($this->formR['raisonSociale'])) {
$request = '';
@ -439,8 +439,7 @@ Class SDmotor
*/
public function removeSmallWord($rs)
{
global $link, $sequence, $wordformRS, $adrRef;
require_once realpath(dirname(__FILE__)) . '/sequence.php';
include 'sequence.php';
$array = explode(' ', $rs);
if(count($array) > 2) {
@ -705,8 +704,8 @@ Class SDmotor
$response = array();
switch($this->index) {
case 'ent':
$sql = 'SELECT raisonSociale, CONCAT(siren, nic) AS siret, siren, nic, siege, raisonSociale,
sigle, enseigne, adr_num, adr_typeVoie, adr_libVoie, adr_comp, adr_cp,
$sql = 'SELECT raisonSociale, CONCAT(siren, nic) AS siret, rang, siren, nic, siege, raisonSociale,
sigle, enseigne, (siren > 200) AS sirenValide, adr_num, adr_typeVoie, adr_libVoie, adr_comp, adr_cp,
adr_ville, tel, fax, cj, actif, ape_etab, ape_entrep FROM etablissements WHERE id IN (';
foreach($resSphinx['matches'] as $elements) {
/*$sql .= 'id='.$elements['id'];*/
@ -715,7 +714,8 @@ Class SDmotor
$sql .= ', ';
$i++;
}
$sql .= ") ORDER BY rang DESC";
$sql .= ") ORDER BY sirenValide DESC, rang DESC, actif DESC, siege DESC";
//echo $sql;exit;
break;
case 'dir':
$sql = 'SELECT e.id, e.raisonSociale, CONCAT(e.siren, e.nic) AS siret, e.siren, e.nic, e.siege, e.raisonSociale,
@ -757,7 +757,11 @@ Class SDmotor
$sql .= ')';
break;
}
$i = 0;
$i = 0;
$response['criteres'] = $this->criteresLetters;
$response['nbReponses'] = $resSphinx['total'];
$response['nbReponsesTotal'] = $resSphinx['total_found'];
$response['duree'] = $this->total_time;
$db = $this->databaseJO();
$result = $db->query($sql);
while($row = mysqli_fetch_assoc($result)) {
@ -918,7 +922,8 @@ Class SDmotor
$this->sphinx = $sphinx;
}
public function execute() {
public function execute($sphinx) {
$this->sphinx = $sphinx;
return $this->search();
}

View File

@ -26,7 +26,7 @@ Class rechercheFonc extends SDmotor
$this->_initForm($formR);
$this->setSphinx($sphinx);
$this->setSequance();
return ($this->execute());
return ($this->execute($sphinx));
}
public function rechercheDir($formR, $deb, $nbRep, $max)
@ -46,10 +46,10 @@ Class rechercheFonc extends SDmotor
$this->_initForm($formR);
$this->setSphinx($sphinx);
$this->setSequance();
return ($this->execute());
return ($this->execute($sphinx));
}
public function rechercheEnt($formR, $deb, $nbRep, $max)
public function rechercheEnt($formR, $deb, $nbRep, $max, $sirenValide = false)
{
$sphinx = new SphinxClient();
$sphinx->SetServer(SPHINX_ENT_HOST, SPHINX_ENT_PORT);
@ -66,7 +66,7 @@ Class rechercheFonc extends SDmotor
$this->_initForm($formR);
$this->setSphinx($sphinx);
$this->setSequance();
return ($this->execute());
return ($this->execute($sphinx));
}
public function rechercheHisto($formR, $deb, $nbRep, $max)