Subversion Repositories eFlore/Projets.eflore-projets

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
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);
53
		foreach ($this->valeurs_insertion as $tab => $res){
54
			if ($tab == 'baseflor') {
55
				foreach ($res as  $valeurs ) {
56
					$requete = "INSERT INTO $table VALUES('',{$valeurs['cle']},null,'".strtolower($valeurs['BDNT']).".nn:{$valeurs['num_nomen']}')";
57
					$this->Bdd->requeter($requete);
58
					$this->message->afficherAvancement('Insertion des valeurs issues de baseflor en cours');
59
				}
60
			} else {
61
				foreach ($res as  $valeurs ) {
62
					$requete = "INSERT INTO $table VALUES('',null,{$valeurs['cle']},'{$valeurs['bdnt']}.nn{$valeurs['num_nomen']}')";
63
					$this->Bdd->requeter($requete);
64
					$this->message->afficherAvancement('Insertion des valeurs issues des rangs supérieurs en cours');
65
				}
66
			}
67
		}
68
	}
69
 
70
}
71
?>