forked from science-ation/science-ation
Adding conferences_id to the last two tables that need it
This commit is contained in:
parent
89475dae93
commit
1c1a0673c3
@ -1 +1 @@
|
||||
217
|
||||
218
|
||||
|
32
db/db.update.218.php
Normal file
32
db/db.update.218.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?
|
||||
function db_update_218_pre()
|
||||
{
|
||||
}
|
||||
|
||||
function db_update_218_post()
|
||||
{
|
||||
$tables=array(
|
||||
'questions',
|
||||
'fairs_stats'
|
||||
);
|
||||
|
||||
// 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";
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Reference in New Issue
Block a user