Subversion Repositories eFlore/Projets.eflore-projets

Rev

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

Rev 577 Rev 639
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->genererChampNumNomRetenu();
18
		    		break;
19
		    		break;
19
	    		case 'chargerStructureSql' :
20
	    		case 'chargerStructureSql' :
20
	    			$this->chargerStructureSql();
21
	    			$this->chargerStructureSql();
21
	    			break;
22
	    			break;
22
				case 'chargerDonnees' :
23
				case 'chargerDonnees' :
23
		    		$this->chargerDonnees('especes');
24
		    		$this->chargerDonnees('especes');
24
		    		$this->chargerDonnees('lois');
25
		    		$this->chargerDonnees('lois');
-
 
26
		    		$this->genererChampNumNomRetenu();
-
 
27
					break;
-
 
28
				case 'genererChampNumNomRetenu' :
-
 
29
					$this->genererChampNumNomRetenu();
25
					break;
30
					break;
26
				case 'supprimerTous' :
31
				case 'supprimerTous' :
27
					$this->supprimerTous();
32
					$this->supprimerTous();
28
					break;
33
					break;
29
				default :
34
				default :
Line 45... Line 50...
45
			"	ENCLOSED BY '' ".
50
			"	ENCLOSED BY '' ".
46
			"	ESCAPED BY '\\\' ".
51
			"	ESCAPED BY '\\\' ".
47
			'IGNORE 1 LINES';
52
			'IGNORE 1 LINES';
48
		$this->getBdd()->requeter($requete);
53
		$this->getBdd()->requeter($requete);
49
	}
54
	}
-
 
55
	
-
 
56
	private function genererChampNumNomRetenu() {
-
 
57
		$this->preparerTablePrChpNumNomRetenu();
-
 
58
		$this->genererNumNomRetenu();
-
 
59
	}
-
 
60
	
-
 
61
	private function preparerTablePrChpNumNomRetenu() {
-
 
62
		$table = Config::get('tables.especes');
-
 
63
		$requete = "SHOW COLUMNS FROM $table LIKE 'num_nom_retenu' ";
-
 
64
		$resultat = $this->getBdd()->recuperer($requete);
-
 
65
		if ($resultat === false) {
-
 
66
			$requete = 	"ALTER TABLE $table ".
-
 
67
					'ADD num_nom_retenu INT(10) '.
-
 
68
					'NULL DEFAULT NULL AFTER num_nom';
-
 
69
			$this->getBdd()->requeter($requete);
-
 
70
		}
-
 
71
	}
-
 
72
	
-
 
73
	private function genererNumNomRetenu() {
-
 
74
		$table = Config::get('tables.especes');
-
 
75
		$table_referentiel = Config::get('tables.referentielTaxo');
-
 
76
		
-
 
77
		$requete = 'UPDATE '.$table.' s, '.$table_referentiel.' r '.
-
 
78
		           'SET s.num_nom_retenu = r.num_nom_retenu '.
-
 
79
		           '	WHERE s.num_nom = r.num_nom ';
-
 
80
		
-
 
81
		$this->getBdd()->requeter($requete);
-
 
82
	}
Line 50... Line 83...
50
 
83
 
51
	private function supprimerTous() {
84
	private function supprimerTous() {
52
		$requete = "DROP TABLE IF EXISTS sptb_meta, sptb_especes_v2012, sptb_lois_v2012";
85
		$requete = "DROP TABLE IF EXISTS sptb_meta, sptb_especes_v2012, sptb_lois_v2012";
53
		$this->getBdd()->requeter($requete);
86
		$this->getBdd()->requeter($requete);