Subversion Repositories eFlore/Projets.eflore-projets

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
77 jpm 1
<?php
2
/** Exemple lancement:
3
 * /opt/lampp/bin/php -d memory_limit=3500M ~/web/eflore-projets/scripts/cli.php bdnt -a chargerTous
4
*/
5
class Bdnt extends EfloreScript {
6
 
7
	public function executer() {
8
		// Lancement de l'action demandée
9
		try {
10
			$this->initialiserProjet('bdnt');
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;
130 jpm 24
				case 'supprimerTous' :
25
					$this->supprimerTous();
26
					break;
77 jpm 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 0 LINES';
46
		$this->getBdd()->requeter($requete);
47
	}
130 jpm 48
 
49
	private function supprimerTous() {
349 jpm 50
		$requete = "DROP TABLE IF EXISTS bdnt_meta, bdnt_ontologies_v4_30";
130 jpm 51
		$this->getBdd()->requeter($requete);
52
	}
77 jpm 53
}
54
?>