24,7 → 24,7 |
class Informations extends Commun { |
|
protected $limite_requete = array( 'depart' => 0, 'limite' => 10); |
private $table = ""; |
private $tables; |
private $champs_recherches = '*'; |
private $requete_jointure = ""; |
private $requete_condition = ""; |
38,6 → 38,11 |
if (empty($this->ressources)){ |
$this->traiterParametres(); |
} |
$this->definirTables(array ('index' => config::get('bdd_table_index'), |
'baseflor' => config::get('bdd_table'), |
'rangSup' => config::get('bdd_table_rang_sup') |
) |
); |
$this->traiterRessources(); |
$requete = $this->assemblerLaRequete(); |
$resultat = $this->Bdd->recupererTous($requete); |
53,11 → 58,6 |
public function __construct() { |
$Conteneur = new Conteneur(); |
$this->Bdd = $Conteneur ->getBdd(); |
$prefixe_table = array ('index' => config::get('bdd_table_index'), |
'baseflor' => config::get('bdd_table'), |
'rangSup' => config::get('bdd_table_rang_sup')); |
$this->tables = $this->definirTables($prefixe_table); |
$this->table = $this->tables['index']; |
} |
|
public function renvoyerResultat($resultat) { |
79,12 → 79,11 |
|
public function traiterRessources() { |
if (empty($this->ressources)) { |
|
$this->requete_jointure = array( |
'LEFT JOIN '. $this->tables['baseflor'].' ON ' |
.$this->tables['baseflor'].".cle =".$this->table.".baseflor", |
.$this->tables['baseflor'].".cle =".$this->tables['index'].".baseflor", |
'LEFT JOIN '. $this->tables['rangSup'].' ON ' |
.$this->tables['rangSup'].".cle = ".$this->table.".RangSup"); |
.$this->tables['rangSup'].".cle = ".$this->tables['index'].".RangSup"); |
|
$this->champs_recherches = " {$this->tables['baseflor']}.num_nomen as 'baseflor.nn', |
{$this->tables['baseflor']}.BDNT as 'baseflor.bdnt', |
92,7 → 91,7 |
{$this->tables['baseflor']}.num_taxon , |
{$this->tables['rangSup']}.num_nomen as 'rangSup.nn', |
{$this->tables['rangSup']}.bdnt as 'rangSup.bdnt', |
{$this->table}.cle as 'index.cle' "; |
{$this->tables['index']}.cle as 'index.cle' "; |
} else { |
if(preg_match('/^(.+)\.nn:([0-9]+)$/', $this->ressources[0], $retour)){ |
$this->champs_recherches = " baseflor, rangSup "; |
147,7 → 146,7 |
} |
} |
|
public function DefinirTables($prefixe_table) { |
public function definirTables($prefixe_table) { |
$table_num_version = $this->recupererVersionDisponible(); |
foreach ($prefixe_table as $nom => $prefixe ) { |
if ( in_array($this->version_projet,$table_num_version) ) { |
160,7 → 159,7 |
throw new Exception($e, RestServeur::HTTP_CODE_MAUVAISE_REQUETE); |
} |
} |
return $tables; |
$this->tables = $tables; |
} |
|
|
215,7 → 214,7 |
|
|
public function assemblerLaRequete() { |
$requete = ' SELECT '.$this->champs_recherches.' FROM '.$this->table.' ' |
$requete = ' SELECT '.$this->champs_recherches.' FROM '.$this->tables['index'].' ' |
.$this->retournerRequeteJointure().' '.$this->retournerRequeteCondition(). |
' '.$this->delimiterResultatsRequete(); |
return $requete; |
231,7 → 230,7 |
|
|
public function calculerTotalResultat() { |
$requete = 'SELECT count(*) as nombre FROM '.$this->table; |
$requete = 'SELECT count(*) as nombre FROM '.$this->tables['index']; |
$res = $this->getBdd()->recuperer($requete); |
if ($res) { |
$this->total_resultat = $res['nombre']; |