Skip to content
Snippets Groups Projects
Commit 6e442e02 authored by Olivier PEREZ's avatar Olivier PEREZ
Browse files

Complete the fix of accent problem during migration

parent f40a9e5d
No related branches found
No related tags found
No related merge requests found
......@@ -113,10 +113,10 @@ VALUE (?,?,?,?,?,?,?,?,?,?,?,?)');
$insert->execute([
$row->id_sondage,
$row->id_sondage_admin,
html_entity_decode($row->titre),
html_entity_decode($row->commentaires),
html_entity_decode($row->nom_admin),
html_entity_decode($row->mail_admin),
$this->unescape($row->titre),
$this->unescape($row->commentaires),
$this->unescape($row->nom_admin),
$this->unescape($row->mail_admin),
$row->date_creation,
$row->date_fin,
$row->format,
......@@ -153,7 +153,11 @@ CREATE TABLE IF NOT EXISTS `' . Utils::table('slot') . '` (
$prepared = $pdo->prepare('INSERT INTO ' . Utils::table('slot') . ' (`poll_id`, `title`, `moments`) VALUE (?,?,?)');
foreach ($slots as $slot) {
$prepared->execute([$slot->poll_id, $slot->title, !empty($slot->moments) ? $slot->moments : null]);
$prepared->execute([
$slot->poll_id,
$this->unescape($slot->title),
!empty($slot->moments) ? $this->unescape($slot->moments) : null
]);
}
}
......@@ -186,8 +190,8 @@ VALUE (?,?,?)');
while ($row = $select->fetch(\PDO::FETCH_OBJ)) {
$insert->execute([
$row->id_sondage,
html_entity_decode($row->usercomment),
html_entity_decode($row->comment)
$this->unescape($row->usercomment),
$this->unescape($row->comment)
]);
}
}
......@@ -207,14 +211,24 @@ CREATE TABLE IF NOT EXISTS `' . Utils::table('vote') . '` (
}
private function migrateFromUserStudsToVote(\PDO $pdo) {
$pdo->exec('
INSERT INTO `' . Utils::table('vote') . '`
(`poll_id`, `name`, `choices`)
SELECT
$select = $pdo->query('
SELECT
`id_sondage`,
`nom`,
REPLACE(REPLACE(REPLACE(`reponses`, 1, \'X\'), 2, 1), \'X\', 2)
REPLACE(REPLACE(REPLACE(`reponses`, 1, \'X\'), 2, 1), \'X\', 2) reponses
FROM `user_studs`');
$insert = $pdo->prepare('
INSERT INTO `' . Utils::table('vote') . '` (`poll_id`, `name`, `choices`)
VALUE (?,?,?)');
while ($row = $select->fetch(\PDO::FETCH_OBJ)) {
$insert->execute([
$row->id_sondage,
$this->unescape($row->nom),
$row->reponses
]);
}
}
private function transformSujetToSlot($sujet) {
......@@ -252,4 +266,8 @@ INSERT INTO `' . Utils::table('vote') . '`
$pdo->exec('DROP TABLE `user_studs`');
$pdo->exec('DROP TABLE `sondage`');
}
private function unescape($value) {
return stripslashes(html_entity_decode($value, ENT_QUOTES));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment