Subversion Repositories eFlore/Projets.eflore-projets

Rev

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

Rev 77 Rev 130
1
<?php
1
<?php
2
/** Exemple lancement:
2
/** Exemple lancement:
3
 * /opt/lampp/bin/php -d memory_limit=3500M ~/web/eflore-projets/scripts/cli.php bdnt -a chargerTous
3
 * /opt/lampp/bin/php -d memory_limit=3500M ~/web/eflore-projets/scripts/cli.php bdnt -a chargerTous
4
*/
4
*/
5
class Bdnt extends EfloreScript {
5
class Bdnt 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('bdnt');
10
			$this->initialiserProjet('bdnt');
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 'test' :
24
				case 'test' :
25
					$this->tester();
25
					$this->tester();
26
					break;
26
					break;
-
 
27
				case 'supprimerTous' :
-
 
28
					$this->supprimerTous();
-
 
29
					break;
27
				default :
30
				default :
28
					throw new Exception("Erreur : la commande '$cmd' n'existe pas!");
31
					throw new Exception("Erreur : la commande '$cmd' n'existe pas!");
29
			}
32
			}
30
		} catch (Exception $e) {
33
		} catch (Exception $e) {
31
			$this->traiterErreur($e->getMessage());
34
			$this->traiterErreur($e->getMessage());
32
		}
35
		}
33
    }
36
    }
34
 
37
 
35
    private function tester() {
38
    private function tester() {
36
    	echo Config::get('test');
39
    	echo Config::get('test');
37
    }
40
    }
38
 
41
 
39
	private function chargerOntologies() {
42
	private function chargerOntologies() {
40
		$chemin = Config::get('chemins.ontologies');
43
		$chemin = Config::get('chemins.ontologies');
41
		$table = Config::get('tables.ontologies');
44
		$table = Config::get('tables.ontologies');
42
		$requete = "LOAD DATA INFILE '$chemin' ".
45
		$requete = "LOAD DATA INFILE '$chemin' ".
43
			"REPLACE INTO TABLE $table ".
46
			"REPLACE INTO TABLE $table ".
44
			'CHARACTER SET utf8 '.
47
			'CHARACTER SET utf8 '.
45
			'FIELDS '.
48
			'FIELDS '.
46
			"	TERMINATED BY '\t' ".
49
			"	TERMINATED BY '\t' ".
47
			"	ENCLOSED BY '' ".
50
			"	ENCLOSED BY '' ".
48
			"	ESCAPED BY '\\\' ".
51
			"	ESCAPED BY '\\\' ".
49
			'IGNORE 0 LINES';
52
			'IGNORE 0 LINES';
50
		$this->getBdd()->requeter($requete);
53
		$this->getBdd()->requeter($requete);
-
 
54
	}
-
 
55
 
-
 
56
	private function supprimerTous() {
-
 
57
		$requete = "DROP TABLE bdnt_meta, bdnt_ontologies_v4_30";
-
 
58
		$this->getBdd()->requeter($requete);
51
	}
59
	}
52
}
60
}
53
?>
61
?>