Loading admin/actions/test.php +1 −12 Original line number Diff line number Diff line Loading @@ -3,16 +3,5 @@ $bdd = new \BddAdmin\Bdd(Config::get('bdds', 'dev-local')); $schema = new \BddAdmin\Schema($bdd); $bdd2 = new \BddAdmin\Bdd(Config::get('bdds', 'dev-local')); //$oa->migration('post', 'FormuleTestStructureToString'); \BddAdmin\Event\EventManager::getMain()->listen(null, null, function ($event) { var_dump(get_class($event->sender), $event->action, $event->data); //$event->setReturn('no-exec', true); }); //$r = $bdd->select('select * from annee'); $views = $schema->getDdlObject(\BddAdmin\Ddl\DdlView::class); $views->create(['name' => 'test', 'definition' => 'CREATE OR REPLACE VIEW test AS SELECT * FROM type_intervention']); $views->execQueries(); No newline at end of file $oa->migration(AbstractMigration::CONTEXTE_POST, 'DepartementsInitCodes'); No newline at end of file admin/migration/DepartementsInitCodes.php 0 → 100644 +46 −0 Original line number Diff line number Diff line <?php class DepartementsInitCodes extends AbstractMigration { protected $contexte = self::CONTEXTE_POST; public function description(): string { return "Ajout des codes manquants sur les données par défaut de la table des départements"; } public function utile(): bool { $bdd = $this->oseAdmin->getBdd(); $sql = " SELECT count(*) nbvides FROM departement WHERE code IS NULL AND source_code IS NOT NULL AND source_id=:source"; $res = $bdd->select($sql, ['source' => $this->oseAdmin->getSourceOseId()], \BddAdmin\Bdd::FETCH_ONE); $nbvides = (int)$res['NBVIDES']; return $nbvides > 0; } public function action() { $sql = "UPDATE departement SET code = source_code WHERE code IS NULL AND source_id= :source"; $this->oseAdmin->getBdd()->exec($sql, ['source' => $this->oseAdmin->getSourceOseId()]); } } No newline at end of file Loading
admin/actions/test.php +1 −12 Original line number Diff line number Diff line Loading @@ -3,16 +3,5 @@ $bdd = new \BddAdmin\Bdd(Config::get('bdds', 'dev-local')); $schema = new \BddAdmin\Schema($bdd); $bdd2 = new \BddAdmin\Bdd(Config::get('bdds', 'dev-local')); //$oa->migration('post', 'FormuleTestStructureToString'); \BddAdmin\Event\EventManager::getMain()->listen(null, null, function ($event) { var_dump(get_class($event->sender), $event->action, $event->data); //$event->setReturn('no-exec', true); }); //$r = $bdd->select('select * from annee'); $views = $schema->getDdlObject(\BddAdmin\Ddl\DdlView::class); $views->create(['name' => 'test', 'definition' => 'CREATE OR REPLACE VIEW test AS SELECT * FROM type_intervention']); $views->execQueries(); No newline at end of file $oa->migration(AbstractMigration::CONTEXTE_POST, 'DepartementsInitCodes'); No newline at end of file
admin/migration/DepartementsInitCodes.php 0 → 100644 +46 −0 Original line number Diff line number Diff line <?php class DepartementsInitCodes extends AbstractMigration { protected $contexte = self::CONTEXTE_POST; public function description(): string { return "Ajout des codes manquants sur les données par défaut de la table des départements"; } public function utile(): bool { $bdd = $this->oseAdmin->getBdd(); $sql = " SELECT count(*) nbvides FROM departement WHERE code IS NULL AND source_code IS NOT NULL AND source_id=:source"; $res = $bdd->select($sql, ['source' => $this->oseAdmin->getSourceOseId()], \BddAdmin\Bdd::FETCH_ONE); $nbvides = (int)$res['NBVIDES']; return $nbvides > 0; } public function action() { $sql = "UPDATE departement SET code = source_code WHERE code IS NULL AND source_id= :source"; $this->oseAdmin->getBdd()->exec($sql, ['source' => $this->oseAdmin->getSourceOseId()]); } } No newline at end of file