Subversion Repositories eFlore/Projets.eflore-projets

Rev

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

Rev 1175 Rev 1208
Line 1... Line 1...
1
<?php
1
<?php
2
/** Exemple lancement:
2
/** Exemple lancement:
3
 * /opt/lampp/bin/php -d memory_limit=3500M ~/web/eflore-projets/scripts/cli.php bdnt -a chargerTous
3
 * /opt/lampp/bin/php -d memory_limit=3500M cli.php vigie_flore -a chargerTous
4
*/
4
*/
5
class Photoflora extends EfloreScript {
5
class Photoflora extends EfloreScript {
Line 6... Line 6...
6
 
6
 
7
	public function executer() {
7
	public function executer() {
8
		// Lancement de l'action demandée
8
		// Lancement de l'action demandée
9
		try {
9
		try {
Line 10... Line 10...
10
			$this->initialiserProjet('photoflora');
10
			$this->initialiserProjet('photoflora');
11
 
11
 
12
			$cmd = $this->getParametre('a');
12
			$cmd = $this->getParametre('a');
13
		    switch ($cmd) {
13
			switch ($cmd) {
-
 
14
				case 'chargerTous' :
-
 
15
					$this->chargerStructureSql();
14
		    	case 'chargerTous' :
16
					$this->chargerDonnees();
15
		    		$this->chargerStructureSql();
17
					$this->ajouterOntologie();
16
		    		break;
18
					break;
-
 
19
				case 'chargerStructureSql' :
-
 
20
					$this->chargerStructureSql();
-
 
21
					break;
-
 
22
				case 'chargerDonnees' :
17
	    		case 'chargerStructureSql' :
23
					$this->chargerDonnees();
18
	    			$this->chargerStructureSql();
24
					$this->ajouterOntologie();
-
 
25
					break;
19
	    			break;
26
				case 'ajouterOntologie' :
20
				case 'chargerOntologies' :
27
					$this->ajouterOntologie();
21
					break;
28
					break;
22
				case 'supprimerTous' :
29
				case 'supprimerTous' :
23
					$this->supprimerTous();
30
					$this->supprimerTous();
24
					break;
31
					break;
25
				default :
32
				default :
26
					throw new Exception("Erreur : la commande '$cmd' n'existe pas!");
33
					throw new Exception("Erreur : la commande '$cmd' n'existe pas!");
27
			}
34
			}
28
		} catch (Exception $e) {
35
		} catch (Exception $e) {
29
			$this->traiterErreur($e->getMessage());
36
			$this->traiterErreur($e->getMessage());
Line -... Line 37...
-
 
37
		}
-
 
38
	}
-
 
39
 
-
 
40
	protected function chargerDonnees() {
-
 
41
		$chemin = Config::get('chemins.donnees');
-
 
42
		$table = Config::get('tables.donnees');
-
 
43
		$requete = "LOAD DATA INFILE '$chemin' ".
-
 
44
			"REPLACE INTO TABLE $table ".
-
 
45
			'CHARACTER SET utf8 '.
-
 
46
			'FIELDS '.
-
 
47
			"	TERMINATED BY '\t' ".
-
 
48
			"	ENCLOSED BY '' ".
-
 
49
			"	ESCAPED BY '\\\' ".
-
 
50
			'IGNORE 1 LINES';
-
 
51
		$this->getBdd()->requeter($requete);
-
 
52
	}
-
 
53
	
-
 
54
 
-
 
55
	private function ajouterOntologie() {
-
 
56
		$requete = "INSERT INTO `eflore_ontologies` (`id`, `classe_id`, `nom`, `description`, `code`, `complements`) VALUES
-
 
57
				(26, 10, 'PhotoFlora', 'données issues de la <a href=\"http://www.photoflora.fr\" title=\"PhotoFlora\" onclick=\"window.open(this.href); return false;\">Base de données de photos de plantes essentiellement de la flore européenne</a> par Benoit BOCK avec les données de Jean-Luc TASSET, Christophe BODIN, Bernard TILLY...', 'PF', 'legende=#FFBD00');";
30
		}
58
		$this->getBdd()->requeter($requete);
31
    }
59
	}
32
 
60
	
-
 
61
	private function supprimerTous() {
33
	private function supprimerTous() {
62
		$requete = "DROP TABLE IF EXISTS photoflora_meta;";
34
		$requete = "DROP TABLE IF EXISTS photoflora_meta";
63
		$this->getBdd()->requeter($requete);
35
		$this->getBdd()->requeter($requete);
64
		Debug::printr('suppression');
36
	}
65
	}