522 |
mathilde |
1 |
<?php
|
|
|
2 |
/**
|
|
|
3 |
*
|
|
|
4 |
* @author Mathilde SALTHUN-LASSALLE <mathilde@tela-botanica.org>
|
|
|
5 |
*
|
|
|
6 |
*
|
|
|
7 |
*/
|
|
|
8 |
class BaseflorIndex {
|
|
|
9 |
|
|
|
10 |
private $conteneur;
|
|
|
11 |
private $efloreCommun;
|
|
|
12 |
private $message;
|
|
|
13 |
private $dossierBase;
|
|
|
14 |
private $valeurs_insertion = array();
|
|
|
15 |
private $Bdd;
|
|
|
16 |
|
|
|
17 |
public function __construct(Conteneur $conteneur, Bdd $Bdd) {
|
|
|
18 |
$this->conteneur = $conteneur;
|
|
|
19 |
$this->Bdd = $Bdd;
|
|
|
20 |
$this->efloreCommun = $conteneur->getEfloreCommun();
|
|
|
21 |
$this->message = $conteneur->getMessages();
|
|
|
22 |
$this->dossierBase = dirname(__FILE__).'/';
|
|
|
23 |
}
|
|
|
24 |
|
|
|
25 |
|
|
|
26 |
public function insererDonnees(){
|
|
|
27 |
$this->efloreCommun->chargerFichierSql('chemins.index_sql');
|
|
|
28 |
$this->recupererDonneesBaseflor();
|
|
|
29 |
$this->recupererDonneesRangSup();
|
|
|
30 |
$this->insererDonneesIndex();
|
|
|
31 |
}
|
|
|
32 |
|
|
|
33 |
private function recupererDonneesBaseflor() {
|
|
|
34 |
$table = Config::get('tables.donnees');
|
|
|
35 |
$requete = "SELECT cle, num_nomen, BDNT FROM $table ;";
|
|
|
36 |
$resultat = $this->Bdd->recupererTous($requete);
|
|
|
37 |
$this->valeurs_insertion['baseflor'] = $resultat;
|
|
|
38 |
$this->valeurs_insertion['rangSup'] = $resultat;
|
|
|
39 |
}
|
|
|
40 |
|
|
|
41 |
private function recupererDonneesRangSup() {
|
|
|
42 |
$table = Config::get('tables.rang_sup');
|
|
|
43 |
$requete = "SELECT cle, num_nomen, bdnt FROM $table ;";
|
|
|
44 |
$resultat = $this->Bdd->recupererTous($requete);
|
|
|
45 |
$this->valeurs_insertion['rangSup']= $resultat;
|
|
|
46 |
|
|
|
47 |
}
|
|
|
48 |
|
|
|
49 |
private function insererDonneesIndex() {
|
|
|
50 |
$table = Config::get('tables.index');
|
|
|
51 |
$requete_truncate = 'TRUNCATE TABLE '.$table;
|
|
|
52 |
$this->Bdd->requeter($requete_truncate);
|
891 |
delphine |
53 |
$i = 0;
|
522 |
mathilde |
54 |
foreach ($this->valeurs_insertion as $tab => $res){
|
|
|
55 |
if ($tab == 'baseflor') {
|
|
|
56 |
foreach ($res as $valeurs ) {
|
891 |
delphine |
57 |
$requete = "INSERT INTO $table VALUES({$i},{$valeurs['cle']},null,'".strtolower($valeurs['BDNT']).".nn:{$valeurs['num_nomen']}')";
|
522 |
mathilde |
58 |
$this->Bdd->requeter($requete);
|
891 |
delphine |
59 |
$i++;
|
522 |
mathilde |
60 |
$this->message->afficherAvancement('Insertion des valeurs issues de baseflor en cours');
|
|
|
61 |
}
|
|
|
62 |
} else {
|
|
|
63 |
foreach ($res as $valeurs ) {
|
891 |
delphine |
64 |
$requete = "INSERT INTO $table VALUES({$i},null,{$valeurs['cle']},'{$valeurs['bdnt']}.nn{$valeurs['num_nomen']}')";
|
522 |
mathilde |
65 |
$this->Bdd->requeter($requete);
|
891 |
delphine |
66 |
$i++;
|
522 |
mathilde |
67 |
$this->message->afficherAvancement('Insertion des valeurs issues des rangs supérieurs en cours');
|
|
|
68 |
}
|
|
|
69 |
}
|
|
|
70 |
}
|
|
|
71 |
}
|
|
|
72 |
|
|
|
73 |
}
|
|
|
74 |
?>
|