Migrate all dates to use conferences ONLY, instead of dual conference/FAIRYEAR setup

This commit is contained in:
james 2010-06-23 16:06:01 +00:00
parent 24c80b1654
commit 4faa4b8dc4
5 changed files with 31 additions and 30 deletions

View File

@ -103,7 +103,7 @@ if(!mysql_select_db($DBNAME))
@mysql_query("SET NAMES utf8");
//find out the fair year and any other 'year=0' configuration parameters (things that dont change as the years go on)
$q=@mysql_query("SELECT * FROM config WHERE year='0'");
$q=@mysql_query("SELECT * FROM config WHERE conferences_id=0 OR year=0");
//we might get an error if installation step 2 is not done (ie, the config table doesnt even exist)
if(mysql_error())
@ -242,7 +242,7 @@ if(intval($_SESSION['conferenceid'])>0) {
}
//now pull the rest of the configuration
$q=mysql_query("SELECT * FROM config WHERE year='".$config['FAIRYEAR']."'");
$q=mysql_query("SELECT * FROM config WHERE conferences_id='".$conference['id']."'");
while($r=mysql_fetch_object($q)) {
$config[$r->var]=$r->val;
}
@ -251,7 +251,7 @@ while($r=mysql_fetch_object($q)) {
if($conference['id'])
$q=mysql_query("SELECT * FROM dates WHERE conferences_id='".$conference['id']."'");
else
$q=mysql_query("SELECT * FROM dates WHERE year='".$config['FAIRYEAR']."'");
$config['dates']=array();
while($r=mysql_fetch_object($q)) {
$config['dates'][$r->name]=$r->date;

View File

@ -31,7 +31,7 @@
,"important_dates"
);
$q=mysql_query("SELECT * FROM dates WHERE year='-1'");
$q=mysql_query("SELECT * FROM dates WHERE conferences_id='-1'");
while($r=mysql_fetch_object($q)) {
$defaultdates[$r->name]=$r;
}
@ -87,12 +87,7 @@ $possibledates['scienceolympics'] = array('fairdate' => array() ,
$dates=$possibledates[$conference['type']];
/* Now copy the SQL data into the above array */
if($conference['id']>0) {
$q=mysql_query("SELECT * FROM dates WHERE conferences_id='".$conference['id']."' ORDER BY date");
}
else {
$q=mysql_query("SELECT * FROM dates WHERE year='".$config['FAIRYEAR']."' ORDER BY date");
}
$q=mysql_query("SELECT * FROM dates WHERE conferences_id='".$conference['id']."' ORDER BY date");
while($r=mysql_fetch_object($q)) {
//check if its a date we dont care about
if(!is_array($dates[$r->name]))
@ -142,25 +137,14 @@ foreach($dates as $dn=>$d) {
if(!$d['id']) {
$def=$defaultdates[$dn];
//hmm if we dont have a record for this date this year, INSERT the sql from the default
if($conference['id']>0) {
mysql_query("INSERT INTO dates (date,name,description,year,conferences_id) VALUES (
'".mysql_real_escape_string($def->date)."',
'".mysql_real_escape_string($dn)."',
'".mysql_real_escape_string($def->description)."',
0,
'".$conference['id']."'
)");
echo mysql_error();
}
else {
mysql_query("INSERT INTO dates (date,name,description,year,conferences_id) VALUES (
'".mysql_real_escape_string($def->date)."',
'".mysql_real_escape_string($dn)."',
'".mysql_real_escape_string($def->description)."',
'".$config['FAIRYEAR']."',
0
)");
}
mysql_query("INSERT INTO dates (date,name,description,year,conferences_id) VALUES (
'".mysql_real_escape_string($def->date)."',
'".mysql_real_escape_string($dn)."',
'".mysql_real_escape_string($def->description)."',
0,
'".$conference['id']."'
)");
echo mysql_error();
$d['id']=mysql_insert_id();
$d['description']=$def->description;
$d['date']=$def->date;

View File

@ -1 +1 @@
190
191

16
db/db.update.191.php Normal file
View File

@ -0,0 +1,16 @@
<?
function db_update_191_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 dates for year={$r->year} to conferences_id={$r->id}\n";
mysql_query("UPDATE dates SET conferences_id='$r->id' WHERE year='$r->year'");
}
}
function db_update_191_post()
{
}
?>

1
db/db.update.191.sql Normal file
View File

@ -0,0 +1 @@
UPDATE dates SET conferences_id=-1 WHERE year=-1;