getMessage(), true); } pwg_db_check_charset(); // +-----------------------------------------------------------------------+ // | Upgrades | // +-----------------------------------------------------------------------+ // retrieve already applied upgrades $query = ' SELECT id FROM '.PREFIX_TABLE.'upgrade ;'; $applied = array_from_query($query, 'id'); // retrieve existing upgrades $existing = get_available_upgrade_ids(); // which upgrades need to be applied? $to_apply = array_diff($existing, $applied); echo '
';
echo count($to_apply).' upgrades to apply';

foreach ($to_apply as $upgrade_id)
{
  unset($upgrade_description);

  echo "\n\n";
  echo '=== upgrade '.$upgrade_id."\n";

  // include & execute upgrade script. Each upgrade script must contain
  // $upgrade_description variable which describe briefly what the upgrade
  // script does.
  include(UPGRADES_PATH.'/'.$upgrade_id.'-database.php');

  // notify upgrade
  $query = '
INSERT INTO '.PREFIX_TABLE.'upgrade
  (id, applied, description)
  VALUES
  (\''.$upgrade_id.'\', NOW(), \''.$upgrade_description.'\')
;';
  pwg_query($query);
}

echo '
'; ?>