Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 1175 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1175 Rev 1191
Line 13... Line 13...
13
		    switch ($cmd) {
13
		    switch ($cmd) {
14
		    	case 'chargerTous' :
14
		    	case 'chargerTous' :
15
		    		$this->chargerStructureSql();
15
		    		$this->chargerStructureSql();
16
		    		$this->chargerDonnees('especes');
16
		    		$this->chargerDonnees('especes');
17
		    		$this->chargerDonnees('lois');
17
		    		$this->chargerDonnees('lois');
-
 
18
		    		$this-> ajouterChamps();
18
		    		$this->genererChampNumNomRetenu();
19
		    		$this->genererChampNumNomRetenu();
19
		    		break;
20
		    		break;
20
	    		case 'chargerStructureSql' :
21
	    		case 'chargerStructureSql' :
21
	    			$this->chargerStructureSql();
22
	    			$this->chargerStructureSql();
22
	    			break;
23
	    			break;
23
				case 'chargerDonnees' :
24
				case 'chargerDonnees' :
24
		    		$this->chargerDonnees('especes');
25
		    		$this->chargerDonnees('especes');
25
		    		$this->chargerDonnees('lois');
26
		    		$this->chargerDonnees('lois');
-
 
27
		    		$this-> ajouterChamps();
26
		    		$this->genererChampNumNomRetenu();
28
		    		$this->genererChampNumNomRetenu();
27
					break;
29
					break;
28
				case 'genererChampNumNomRetenu' :
30
				case 'genererChampNumNomRetenu' :
-
 
31
		    		$this-> ajouterChamps();
29
					$this->genererChampNumNomRetenu();
32
					$this->genererChampNumNomRetenu();
30
					break;
33
					break;
31
				case 'supprimerTous' :
34
				case 'supprimerTous' :
32
					$this->supprimerTous();
35
					$this->supprimerTous();
33
					break;
36
					break;
Line 37... Line 40...
37
		} catch (Exception $e) {
40
		} catch (Exception $e) {
38
			$this->traiterErreur($e->getMessage());
41
			$this->traiterErreur($e->getMessage());
39
		}
42
		}
40
    }
43
    }
Line 41... Line 44...
41
 
44
 
42
	private function chargerDonnees($type) {
45
	protected function chargerDonnees($type) {
43
		$chemin = Config::get('chemins.'.$type);
46
		$chemin = Config::get('chemins.'.$type);
44
		$table = Config::get('tables.'.$type);
47
		$table = Config::get('tables.'.$type);
45
		$requete = "LOAD DATA INFILE '$chemin' ".
48
		$requete = "LOAD DATA INFILE '$chemin' ".
46
			"REPLACE INTO TABLE $table ".
49
			"REPLACE INTO TABLE $table ".
Line 67... Line 70...
67
					'ADD num_nom_retenu INT(10) '.
70
					'ADD num_nom_retenu INT(10) '.
68
					'NULL DEFAULT NULL AFTER num_nom';
71
					'NULL DEFAULT NULL AFTER num_nom';
69
			$this->getBdd()->requeter($requete);
72
			$this->getBdd()->requeter($requete);
70
		}
73
		}
71
	}
74
	}
-
 
75
	private function ajouterChamps() {
-
 
76
		$table = Config::get('tables.especes');
-
 
77
		
-
 
78
		$requete = 'ALTER TABLE '.$table.' ADD `num_nom` INT( 10 ) NOT NULL ,
-
 
79
					ADD `num_nom_retenu` INT( 10 ) NOT NULL ,
-
 
80
					ADD `nom_sci` VARCHAR( 70 ) NOT NULL ';
-
 
81
		$this->getBdd()->requeter($requete);
-
 
82
	}
Line 72... Line 83...
72
	
83
	
73
	private function genererNumNomRetenu() {
84
	private function genererNumNomRetenu() {
74
		$table = Config::get('tables.especes');
85
		$table = Config::get('tables.especes');
Line 75... Line 86...
75
		$table_referentiel = Config::get('tables.referentielTaxo');
86
		$table_referentiel = Config::get('tables.referentielTaxo');
76
		
87
		
77
		$requete = 'UPDATE '.$table.' s, '.$table_referentiel.' r '.
88
		$requete = 'UPDATE '.$table.' s, '.$table_referentiel.' r '.
Line 78... Line 89...
78
		           'SET s.num_nom_retenu = r.num_nom_retenu '.
89
		           'SET s.num_nom_retenu = r.num_nom_retenu, s.num_nom = r.num_nom, s.nom_sci = r.nom_sci '.
79
		           '	WHERE s.num_nom = r.num_nom ';
90
		           '	WHERE s.cd_nom = r.cd_nom ';
Line 80... Line 91...
80
		
91