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;
24
				case 'test' :
25
					$this->tester();
26
					break;
130 jpm 27
				case 'supprimerTous' :
28
					$this->supprimerTous();
29
					break;
77 jpm 30
				default :
31
					throw new Exception("Erreur : la commande '$cmd' n'existe pas!");
32
			}
33
		} catch (Exception $e) {
34
			$this->traiterErreur($e->getMessage());
35
		}
36
    }
37
 
38
    private function tester() {
39
    	echo Config::get('test');
40
    }
41
 
42
	private function chargerOntologies() {
43
		$chemin = Config::get('chemins.ontologies');
44
		$table = Config::get('tables.ontologies');
45
		$requete = "LOAD DATA INFILE '$chemin' ".
46
			"REPLACE INTO TABLE $table ".
47
			'CHARACTER SET utf8 '.
48
			'FIELDS '.
49
			"	TERMINATED BY '\t' ".
50
			"	ENCLOSED BY '' ".
51
			"	ESCAPED BY '\\\' ".
52
			'IGNORE 0 LINES';
53
		$this->getBdd()->requeter($requete);
54
	}
130 jpm 55
 
56
	private function supprimerTous() {
57
		$requete = "DROP TABLE bdnt_meta, bdnt_ontologies_v4_30";
58
		$this->getBdd()->requeter($requete);
59
	}
77 jpm 60
}
61
?>