science-ation/db/db.update.117.php

35 lines
713 B
PHP

<?
function db_update_117_post()
{
global $config;
$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='{$head}'");
$q->execute();
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='$id'");
$stmt->execute();
}
/* Now dump the question itself */
$stmt = $pdo->prepare("DELETE FROM questions
WHERE id='$id'");
$stmt->execute();
}
}