Subversion Repositories eFlore/Projets.eflore-projets

Rev

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

Rev Author Line No. Line
11 jpm 1
<?php
40 jpm 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
*/
74 jpm 8
class Iso6391 extends EfloreScript {
40 jpm 9
 
10
	public function executer() {
11
		// Lancement de l'action demandée
12
		try {
74 jpm 13
			$this->initialiserProjet('iso-639-1');
40 jpm 14
 
15
			$cmd = $this->getParametre('a');
16
		    switch ($cmd) {
17
		    	case 'chargerTous' :
18
		    		$this->chargerStructureSql();
19
		    		$this->chargerIso6391();
20
		    		break;
21
	    		case 'chargerStructureSql' :
22
	    			$this->chargerStructureSql();
23
	    			break;
24
				case 'chargerIso6391' :
25
					$this->chargerIso6391();
26
					break;
27
				case 'test' :
28
					$this->tester();
29
					break;
30
				default :
74 jpm 31
					throw new Exception("Erreur : la commande '$cmd' n'existe pas!");
40 jpm 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 chargerIso6391() {
43
		$chemin = Config::get('chemins.iso6391');
44
		$table = Config::get('tables.iso6391');
45
		$requete = "LOAD DATA INFILE '$chemin' ".
46
			"REPLACE INTO TABLE $table ".
47
			'CHARACTER SET utf8 '.
48
			'FIELDS '.
49
			"	TERMINATED BY ';' ".
50
			"	ENCLOSED BY '\"' ".
51
			"	ESCAPED BY '\\\' ".
52
			'IGNORE 0 LINES';
74 jpm 53
		$this->getBdd()->requeter($requete);
40 jpm 54
	}
55
}
56
?>