Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 177 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 177 Rev 349
1
<?php
1
<?php
2
/** Exemple lancement:
2
/** Exemple lancement:
3
 * /opt/lampp/bin/php -d memory_limit=3500M cli.php eflore -a chargerTous
3
 * /opt/lampp/bin/php -d memory_limit=3500M cli.php eflore -a chargerTous
4
*/
4
*/
5
class Eflore extends EfloreScript {
5
class Eflore extends EfloreScript {
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 {
10
			$this->initialiserProjet('eflore');
10
			$this->initialiserProjet('eflore');
11
 
11
 
12
			$cmd = $this->getParametre('a');
12
			$cmd = $this->getParametre('a');
13
		    switch ($cmd) {
13
		    switch ($cmd) {
14
		    	case 'chargerTous' :
14
		    	case 'chargerTous' :
15
		    		$this->chargerStructureSql();
15
		    		$this->chargerStructureSql();
16
		    		$this->chargerOntologies();
16
		    		$this->chargerOntologies();
17
		    		break;
17
		    		break;
18
	    		case 'chargerStructureSql' :
18
	    		case 'chargerStructureSql' :
19
	    			$this->chargerStructureSql();
19
	    			$this->chargerStructureSql();
20
	    			break;
20
	    			break;
21
				case 'chargerOntologies' :
21
				case 'chargerOntologies' :
22
					$this->chargerOntologies();
22
					$this->chargerOntologies();
23
					break;
23
					break;
24
				case 'supprimerTous' :
24
				case 'supprimerTous' :
25
					$this->supprimerTous();
25
					$this->supprimerTous();
26
					break;
26
					break;
27
				default :
27
				default :
28
					throw new Exception("Erreur : la commande '$cmd' n'existe pas!");
28
					throw new Exception("Erreur : la commande '$cmd' n'existe pas!");
29
			}
29
			}
30
		} catch (Exception $e) {
30
		} catch (Exception $e) {
31
			$this->traiterErreur($e->getMessage());
31
			$this->traiterErreur($e->getMessage());
32
		}
32
		}
33
    }
33
    }
34
 
34
 
35
	private function chargerOntologies() {
35
	private function chargerOntologies() {
36
		$chemin = Config::get('chemins.ontologies');
36
		$chemin = Config::get('chemins.ontologies');
37
		$table = Config::get('tables.ontologies');
37
		$table = Config::get('tables.ontologies');
38
		$requete = "LOAD DATA INFILE '$chemin' ".
38
		$requete = "LOAD DATA INFILE '$chemin' ".
39
			"REPLACE INTO TABLE $table ".
39
			"REPLACE INTO TABLE $table ".
40
			'CHARACTER SET utf8 '.
40
			'CHARACTER SET utf8 '.
41
			'FIELDS '.
41
			'FIELDS '.
42
			"	TERMINATED BY '\t' ".
42
			"	TERMINATED BY '\t' ".
43
			"	ENCLOSED BY '\"' ".
43
			"	ENCLOSED BY '\"' ".
44
			"	ESCAPED BY '\\\' ".
44
			"	ESCAPED BY '\\\' ".
45
			'IGNORE 1 LINES';
45
			'IGNORE 1 LINES';
46
		$this->getBdd()->requeter($requete);
46
		$this->getBdd()->requeter($requete);
47
	}
47
	}
48
 
48
 
49
	private function supprimerTous() {
49
	private function supprimerTous() {
50
		$requete = "DROP TABLE eflore_meta, eflore_ontologies_v2011";
50
		$requete = "DROP TABLE IF EXISTS eflore_meta, eflore_ontologies_v2011";
51
		$this->getBdd()->requeter($requete);
51
		$this->getBdd()->requeter($requete);
52
	}
52
	}
53
}
53
}
54
?>
54
?>