Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 130 | 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;
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 tester() {
36
    	echo Config::get('test');
37
    }
38
 
39
	private function chargerOntologies() {
40
		$chemin = Config::get('chemins.ontologies');
41
		$table = Config::get('tables.ontologies');
42
		$requete = "LOAD DATA INFILE '$chemin' ".
43
			"REPLACE INTO TABLE $table ".
44
			'CHARACTER SET utf8 '.
45
			'FIELDS '.
46
			"	TERMINATED BY '\t' ".
47
			"	ENCLOSED BY '' ".
48
			"	ESCAPED BY '\\\' ".
49
			'IGNORE 0 LINES';
50
		$this->getBdd()->requeter($requete);
51
	}
52
}
53
?>