Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 177 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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