forked from science-ation/science-ation
b7f3274543
- split into system variables and conference variables - rely on conference_id instead of year
33 lines
1.1 KiB
PHP
33 lines
1.1 KiB
PHP
<?
|
|
function db_update_190_pre()
|
|
{
|
|
//before we do this, make sure we set the configuration variables based on the conferences.
|
|
$q=mysql_query("SELECT * FROM conferences WHERE type='sciencefair' AND year>0");
|
|
while($r=mysql_fetch_object($q)) {
|
|
echo " Updating config for year={$r->year} to conferences_id={$r->id}\n";
|
|
mysql_query("UPDATE config SET conferences_id='$r->id' WHERE year='$r->year'");
|
|
}
|
|
}
|
|
|
|
function db_update_190_post()
|
|
{
|
|
global $config;
|
|
$q=mysql_query("SELECT DISTINCT var FROM config WHERE section='system'");
|
|
while($r=mysql_fetch_object($q)) {
|
|
echo " Upgrading system variable $r->var ... ";
|
|
$q2=mysql_query("SELECT * FROM config WHERE var='$r->var' ORDER BY year DESC LIMIT 1");
|
|
$r2=mysql_fetch_object($q2);
|
|
if($r2->year!=0) {
|
|
echo " copying from year {$r2->year} ... ";
|
|
mysql_query("UPDATE config SET conferences_id=0, year=0 WHERE var='$r->var' AND year='$r2->year'");
|
|
}
|
|
else
|
|
echo " no year based record to udpate ";
|
|
|
|
mysql_query("DELETE FROM config WHERE var='$r->var' AND (conferences_id>0 OR year>0)");
|
|
echo " deleted ".mysql_affected_rows()." old year-based records\n";
|
|
}
|
|
}
|
|
|
|
?>
|