2427 |
jpm |
1 |
<?php
|
|
|
2 |
// declare(encoding='UTF-8');
|
|
|
3 |
/**
|
|
|
4 |
* Réalise la mise à jour de la base de données vis à vis du travail d'optimisation.
|
|
|
5 |
*
|
|
|
6 |
* @category CEL
|
|
|
7 |
* @package Scripts
|
|
|
8 |
* @subpackage Migration : Optimisation
|
|
|
9 |
* @author Mathias CHOUET <mathias@tela-botanica.org>
|
|
|
10 |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
|
|
|
11 |
* @author Aurelien PERONNET <aurelien@tela-botanica.org>
|
|
|
12 |
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
|
|
|
13 |
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
|
|
|
14 |
* @copyright 1999-2014 Tela Botanica <accueil@tela-botanica.org>
|
|
|
15 |
*/
|
|
|
16 |
class MajOptimisation {
|
|
|
17 |
|
|
|
18 |
private $conteneur;
|
|
|
19 |
private $bdd;
|
|
|
20 |
|
|
|
21 |
public function __construct($conteneur) {
|
|
|
22 |
$this->conteneur = $conteneur;
|
|
|
23 |
$this->bdd = $this->conteneur->getBdd();
|
|
|
24 |
}
|
|
|
25 |
|
|
|
26 |
public function executer() {
|
|
|
27 |
$fichierSql = '../doc/bdd/2014-09_migration_optimisation/maj_optimisation.sql';
|
|
|
28 |
$contenuSql = FichierUtil::recupererContenu($fichierSql);
|
|
|
29 |
$this->executerScripSql($contenuSql);
|
|
|
30 |
}
|
|
|
31 |
|
|
|
32 |
private function executerScripSql($sql) {
|
|
|
33 |
$requetes = SqlUtil::extraireRequetes($sql);
|
|
|
34 |
$nbreRequetes = count($requetes);
|
|
|
35 |
foreach ($requetes as $index => $requete) {
|
|
|
36 |
$num = $index + 1;
|
|
|
37 |
echo "Exécution de la requete $num/$nbreRequetes :\n $requete\n\n";
|
|
|
38 |
$retour = $this->bdd->executer($requete);
|
|
|
39 |
if ($retour === false) {
|
|
|
40 |
throw new Exception("Un problème est survenu avec la requête $requete\n");
|
|
|
41 |
}
|
|
|
42 |
}
|
|
|
43 |
}
|
|
|
44 |
}
|