science-ation/db/db.update.117.php
2025-02-09 17:24:37 +00:00

29 lines
712 B
PHP

<?
function db_update_117_post()
{
global $config, $pdo;
$qmap = array('years_school' => 'Years School',
'years_regional' => 'Years Regional',
'years_national' => 'Years National',
'willing_chair' => 'Willing Chair');
foreach ($qmap as $field => $head) {
$q = $pdo->prepare("SELECT id FROM questions WHERE db_heading=?");
$q->execute([$head]);
while ($i = $q->fetch(PDO::FETCH_OBJ)) {
$id = $i->id;
/* Drop all answers for this question */
$stmt = $pdo->prepare("DELETE FROM question_answers
WHERE questions_id=?");
$stmt->execute([$id]);
}
/* Now dump the question itself */
$stmt = $pdo->prepare("DELETE FROM questions
WHERE id=?");
$stmt->execute([$id]);
}
}