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"; } } ?>