real_query("RENAME TABLE `$t` TO `{$prefix}$t`"); } } function conv_db($mysqli, $old_prefix) { /* Figure out which years to convert */ $skip_years = array(); $q = $mysqli->query("SELECT DISTINCT(year) FROM users WHERE year>0"); while($r = $q->fetch_assoc()) { $skip_years[] = (int)$r['year']; } /* Get years in the old database */ $years = array(); $q = $mysqli->query("SELECT DISTINCT(year) FROM {$old_prefix}config WHERE year>1"); while($r = $q->fetch_assoc()) { $y = (int)$r['year']; if(!in_array($y, $skip_years)) { $years[] = $y; } } sort($years); print(" Will convert years: ".join(', ', $years)."\n"); conv_config($mysqli, $old_prefix); sfiab_load_config($mysqli); load_sponsors($mysqli, $old_prefix); conv_reports($mysqli, $old_prefix); conv_fairs($mysqli, $old_prefix); conv_emails($mysqli, $old_prefix); foreach($years as $year) { conv_categories($mysqli, $old_prefix, $year); conv_schools($mysqli, $old_prefix, $year); conv_tours($mysqli, $old_prefix, $year); } foreach($years as $year) { clear_sponsors($mysqli, $year); conv_awards($mysqli, $old_prefix, $year); conv_students($mysqli, $old_prefix, $year); conv_winners($mysqli, $old_prefix, $year); conv_judges($mysqli, $old_prefix, $year); conv_committee($mysqli, $old_prefix, $year); conv_volunteers($mysqli, $old_prefix, $year); } } ?>