Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 891 | Details | Compare with Previous | 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');
905 delphine 35
		$requete = "SELECT cle, num_nomen, BDNT FROM $table WHERE num_nomen != 0 ".
36
			"	AND num_nomen != 0 ".
37
			"	AND !(ve_lumiere = '' and ve_mat_org_sol = '' and ve_temperature = '' and ve_continentalite = '' ".
38
			"	and ve_humidite_atmos = ''  and ve_humidite_edaph = '' and ve_nutriments_sol = '' and ve_salinite = ''".
39
			"	and ve_texture_sol = '' and ve_reaction_sol = '')";
522 mathilde 40
		$resultat = $this->Bdd->recupererTous($requete);
41
		$this->valeurs_insertion['baseflor'] = $resultat;
42
		$this->valeurs_insertion['rangSup'] = $resultat;
43
	}
44
 
45
	private function recupererDonneesRangSup() {
46
		$table = Config::get('tables.rang_sup');
47
		$requete = "SELECT cle, num_nomen, bdnt FROM $table ;";
48
		$resultat = $this->Bdd->recupererTous($requete);
49
		$this->valeurs_insertion['rangSup']= $resultat;
50
 
51
	}
905 delphine 52
 
522 mathilde 53
 
54
	private function insererDonneesIndex() {
55
		$table = Config::get('tables.index');
56
		$requete_truncate = 'TRUNCATE TABLE '.$table;
57
		$this->Bdd->requeter($requete_truncate);
891 delphine 58
		$i = 0;
522 mathilde 59
		foreach ($this->valeurs_insertion as $tab => $res){
60
			if ($tab == 'baseflor') {
61
				foreach ($res as  $valeurs ) {
905 delphine 62
					if ($valeurs['num_nomen'] != 0) {
63
						$requete = "INSERT INTO $table VALUES({$i},{$valeurs['cle']},null,'".strtolower($valeurs['BDNT']).".nn:{$valeurs['num_nomen']}')";
64
						$this->Bdd->requeter($requete);
65
						$i++;
66
						$this->message->afficherAvancement('Insertion des valeurs issues de baseflor en cours');
67
					}
522 mathilde 68
				}
69
			} else {
70
				foreach ($res as  $valeurs ) {
905 delphine 71
					if ($valeurs['num_nomen'] != 0) {
72
						$requete = "INSERT INTO $table VALUES({$i},null,{$valeurs['cle']},'{$valeurs['bdnt']}.nn:{$valeurs['num_nomen']}')";
73
						$this->Bdd->requeter($requete);
74
						$i++;
75
						$this->message->afficherAvancement('Insertion des valeurs issues des rangs supérieurs en cours');
76
					}
522 mathilde 77
				}
78
			}
79
		}
80
	}
81
 
82
}
83
?>