Rev 905 | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?php
/**
*
* @author Mathilde SALTHUN-LASSALLE <mathilde@tela-botanica.org>
*
*
*/
class BaseflorIndex {
private $conteneur;
private $efloreCommun;
private $message;
private $dossierBase;
private $valeurs_insertion = array();
private $Bdd;
public function __construct(Conteneur $conteneur, Bdd $Bdd) {
$this->conteneur = $conteneur;
$this->Bdd = $Bdd;
$this->efloreCommun = $conteneur->getEfloreCommun();
$this->message = $conteneur->getMessages();
$this->dossierBase = dirname(__FILE__).'/';
}
public function insererDonnees(){
$this->efloreCommun->chargerFichierSql('chemins.index_sql');
$this->recupererDonneesBaseflor();
$this->recupererDonneesRangSup();
$this->insererDonneesIndex();
}
private function recupererDonneesBaseflor() {
$table = Config::get('tables.donnees');
$requete = "SELECT cle, num_nomen, BDNT FROM $table WHERE num_nomen != 0 ".
" AND num_nomen != 0 ".
" AND !(ve_lumiere = '' and ve_mat_org_sol = '' and ve_temperature = '' and ve_continentalite = '' ".
" and ve_humidite_atmos = '' and ve_humidite_edaph = '' and ve_nutriments_sol = '' and ve_salinite = ''".
" and ve_texture_sol = '' and ve_reaction_sol = '')";
$resultat = $this->Bdd->recupererTous($requete);
$this->valeurs_insertion['baseflor'] = $resultat;
$this->valeurs_insertion['rangSup'] = $resultat;
}
private function recupererDonneesRangSup() {
$table = Config::get('tables.rang_sup');
$requete = "SELECT cle, num_nomen, bdnt FROM $table ;";
$resultat = $this->Bdd->recupererTous($requete);
$this->valeurs_insertion['rangSup']= $resultat;
}
private function insererDonneesIndex() {
$table = Config::get('tables.index');
$requete_truncate = 'TRUNCATE TABLE '.$table;
$this->Bdd->requeter($requete_truncate);
$i = 0;
foreach ($this->valeurs_insertion as $tab => $res){
if ($tab == 'baseflor') {
foreach ($res as $valeurs ) {
if ($valeurs['num_nomen'] != 0) {
$requete = "INSERT INTO $table VALUES({$i},{$valeurs['cle']},null,'".strtolower($valeurs['BDNT']).".nn:{$valeurs['num_nomen']}')";
$this->Bdd->requeter($requete);
$i++;
$this->message->afficherAvancement('Insertion des valeurs issues de baseflor en cours');
}
}
} else {
foreach ($res as $valeurs ) {
if ($valeurs['num_nomen'] != 0) {
$requete = "INSERT INTO $table VALUES({$i},null,{$valeurs['cle']},'{$valeurs['bdnt']}.nn:{$valeurs['num_nomen']}')";
$this->Bdd->requeter($requete);
$i++;
$this->message->afficherAvancement('Insertion des valeurs issues des rangs supérieurs en cours');
}
}
}
}
}
}
?>