forked from science-ation/science-ation
b9bcb127a6
award_awards award_prizes award_types award_awards_projectcategories award_awards_projectdivisions winners students projects registrations Also modified all code that uses those tables to work with the conference id instead of the year, with the exception of these files: communication.inc.php reports_students.inc.php rerollprizes.php remote.php The "rerollprizes.php" probably doesn't matter, having been a one-time usage file anyway. The others will need to be modified in the future to correctly use the conference id instead of the year.
45 lines
1022 B
PHP
45 lines
1022 B
PHP
<?
|
|
function db_update_216_pre()
|
|
{
|
|
}
|
|
|
|
function db_update_216_post()
|
|
{
|
|
$tables=array(
|
|
"award_awards",
|
|
"award_prizes",
|
|
"award_types",
|
|
"award_awards_projectcategories",
|
|
"award_awards_projectdivisions",
|
|
"winners",
|
|
"students",
|
|
"projects",
|
|
"registrations"
|
|
);
|
|
|
|
// add the conferences_id field
|
|
foreach($tables as $tableName){
|
|
$query = "ALTER TABLE `$tableName` ADD `conferences_id` INT NOT NULL";
|
|
mysql_query($query);
|
|
echo $query . ";\n";
|
|
}
|
|
|
|
// get the year => conference_id links
|
|
$q1 = mysql_query("SELECT year, id FROM conferences WHERE year > 0");
|
|
|
|
// add the conferences_id field to each table
|
|
while($r = mysql_fetch_assoc($q1)){
|
|
foreach($tables as $tableName){
|
|
$query = "UPDATE `$tableName` SET `conferences_id` = {$r['id']} WHERE `year` = {$r['year']}";
|
|
mysql_query($query);
|
|
echo $query . ";\n";
|
|
}
|
|
}
|
|
|
|
// a one-off update unique to the award_prizes table
|
|
$query = "UPDATE award_prizes SET conferences_id = -1 WHERE year = -1";
|
|
mysql_query($query);
|
|
echo $query . ";\n";
|
|
}
|
|
?>
|