Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 2418 Rev 2427
1
<?php
1
<?php
2
// declare(encoding='UTF-8');
2
// declare(encoding='UTF-8');
3
/**
3
/**
4
 * Mise à jour de la base de données afin de l'optimiser :
4
 * Mise à jour de la base de données afin de l'optimiser :
5
 * - remplacement du champ "eflore_publiable" de la table "cel_images" par un champ "transmission" (correspondant au champ tansmission des obs)
5
 * - remplacement du champ "eflore_publiable" de la table "cel_images" par un champ "transmission" (correspondant au champ tansmission des obs)
6
 * - ajout du champ "date_liaison" dans la table "cel_images"
6
 * - ajout du champ "date_liaison" dans la table "cel_images"
7
 * - ajout du champ "ce_observation" dans la table "cel_images"
7
 * - ajout du champ "ce_observation" dans la table "cel_images"
8
 * - migration des données de la table cel_obs_images dans cel_images
8
 * - migration des données de la table cel_obs_images dans cel_images
9
 * - création d'un index sur cel_images.ce_observation
9
 * - création d'un index sur cel_images.ce_observation
10
 * - suppression de la table cel_obs_images
10
 * - suppression de la table cel_obs_images
11
 *
11
 *
12
 * Utilisation :
12
 * Utilisation :
13
 * - mise à jour de la bdd : <code>/opt/lamp/bin/php cli.php migration_optimisation -a migrer</code>
13
 * - mise à jour de la bdd : <code>/opt/lamp/bin/php cli.php migration_optimisation -a migrer</code>
14
 *
14
 *
15
 * @category   CEL
15
 * @category   CEL
16
 * @package    Scripts
16
 * @package    Scripts
17
 * @subpackage Migration : Optimisation
17
 * @subpackage Migration : Optimisation
18
 * @author     Mathias CHOUET <mathias@tela-botanica.org>
18
 * @author     Mathias CHOUET <mathias@tela-botanica.org>
19
 * @author     Jean-Pascal MILCENT <jpm@tela-botanica.org>
19
 * @author     Jean-Pascal MILCENT <jpm@tela-botanica.org>
20
 * @author     Aurelien PERONNET <aurelien@tela-botanica.org>
20
 * @author     Aurelien PERONNET <aurelien@tela-botanica.org>
21
 * @license    GPL v3 <http://www.gnu.org/licenses/gpl.txt>
21
 * @license    GPL v3 <http://www.gnu.org/licenses/gpl.txt>
22
 * @license    CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
22
 * @license    CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
23
 * @copyright  1999-2014 Tela Botanica <accueil@tela-botanica.org>
23
 * @copyright  1999-2014 Tela Botanica <accueil@tela-botanica.org>
24
 */
24
 */
25
class MigrationOptimisation extends Script {
25
class MigrationOptimisation extends CelScript {
26
 
26
 
27
	public function executer() {
27
	public function executer() {
28
		$cmd = $this->getParametre('a');
28
		try {
-
 
29
			$this->initialiserProjet('migration_optimisation');
-
 
30
 
29
		$this->mode_verbeux = $this->getParametre('v');
31
			// Lancement de l'action demandée
30
 
32
			$cmd = $this->getParametre('a');
-
 
33
			switch ($cmd) {
31
		switch($cmd) {
34
				case 'maj' :
32
			case 'maj':
35
					$script = $this->chargerClasse('MajOptimisation');
33
				$this->migrerBdd();
36
					$script->executer();
-
 
37
					break;
-
 
38
				default :
34
				break;
39
					throw new Exception("Erreur : la commande '$cmd' n'existe pas!");
-
 
40
			}
35
			default:
41
		} catch (Exception $e) {
36
				echo "Action «$cmd» inconnue.\n";
42
			$this->traiterErreur($e->getMessage());
37
		}
43
		}
38
	}
44
	}
39
 
-
 
40
	private function migrerBdd() {
-
 
41
		$contenuSql = FichierUtil::recupererContenu(__DIR__.'/maj_optimisation.sql');
-
 
42
		$this->executerScripSql($contenuSql);
-
 
43
	}
-
 
44
 
45
 
45
	private function executerScripSql($sql) {
-
 
46
		$requetes = SqlUtil::extraireRequetes($sql);
46
	private function chargerClasse($classe) {
47
		foreach ($requetes as $requete) {
47
		require_once $classe.'.php';
48
			echo "Exécution de la requete : $requete\n";
48
		$conteneur = new Conteneur($this->parametres);
49
			$this->executer($requete);
-
 
50
		}
49
		return new $classe($conteneur);
51
	}
50
	}
52
}
51
}