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
70 jpm 1
<?php
2
/** Exemple lancement:
3
 * /opt/lampp/bin/php -d memory_limit=3500M ~/web/eflore-projets/scripts/cli.php iso6391
4
 * 		-a chargerTous
5
 * Options :
6
 * -t : Permet de tester le script sur un jeux réduit de données (indiquer le nombre de lignes).
7
*/
8
class Iso31661 extends EfloreScript {
9
 
10
	public function executer() {
11
		// Lancement de l'action demandée
12
		try {
13
			$this->initialiserProjet('iso-3166-1');
14
 
15
			$cmd = $this->getParametre('a');
16
		    switch ($cmd) {
17
		    	case 'chargerTous' :
18
		    		$this->chargerStructureSql();
19
		    		$this->chargerIso31661();
20
		    		$this->chargerOntologies();
21
		    		break;
22
	    		case 'chargerStructureSql' :
23
	    			$this->chargerStructureSql();
24
	    			break;
25
				case 'chargerIso31661' :
26
					$this->chargerIso31661();
27
					break;
28
				case 'chargerOntologies' :
29
					$this->chargerOntologies();
30
					break;
31
				case 'test' :
32
					$this->tester();
33
					break;
34
				default :
35
					$this->traiterErreur('Erreur : la commande "%s" n\'existe pas!', array($cmd));
36
			}
37
		} catch (Exception $e) {
38
			$this->traiterErreur($e->getMessage());
39
		}
40
    }
41
 
42
    private function tester() {
43
    	echo Config::get('test');
44
    }
45
 
46
	private function chargerIso31661() {
47
		$chemin = Config::get('chemins.iso31661');
48
		$table = Config::get('tables.iso31661');
49
		$requete = "LOAD DATA INFILE '$chemin' ".
50
			"REPLACE INTO TABLE $table ".
51
			'CHARACTER SET utf8 '.
52
			'FIELDS '.
53
			"	TERMINATED BY '\t' ".
54
			"	ENCLOSED BY '\"' ".
55
			"	ESCAPED BY '\\\' ".
56
			'IGNORE 1 LINES';
57
		$this->getBdd()->requeter($requete);
58
	}
59
 
60
	private function chargerOntologies() {
61
		$chemin = Config::get('chemins.ontologies');
62
		$table = Config::get('tables.ontologies');
63
		$requete = "LOAD DATA INFILE '$chemin' ".
64
				"REPLACE INTO TABLE $table ".
65
				'CHARACTER SET utf8 '.
66
				'FIELDS '.
67
				"	TERMINATED BY '\t' ".
68
				"	ENCLOSED BY '\"' ".
69
				"	ESCAPED BY '\\\' ".
70
				'IGNORE 1 LINES';
71
		$this->getBdd()->requeter($requete);
72
	}
73
}
74
?>