예제 #1
0
 /**
  * Update the database structure if needed. This function includes all
  * the incremental steps needed to bring the database up to the latest
  * standard.
  * Basically, this function is a big switch on the data version value
  * with each case falling through to the next one.
  */
 public static function updateTables($dataVersion)
 {
     switch ($dataVersion) {
         case "":
         case "v0.1":
             // No data version yet - create initial table
             if (!Trip::createTripTable()) {
                 return false;
             }
         case "v0.2":
             if (!Trip::createTripAttributeTable()) {
                 return false;
             }
             break;
         case "v0.3":
         case "v0.4":
         case "v0.5":
         case "v0.6":
         case "v0.7":
         case "v0.8":
         case "v0.9":
         case "v0.10":
             if (!Trip::addDeletedColumn()) {
                 return false;
             }
         case "v0.11":
         case "v0.12":
         case "v0.13":
         case "v0.14":
         case "v0.15":
             if (!Trip::addDescriptionColumn()) {
                 return false;
             }
             if (!Trip::addBannerImgColumn()) {
                 return false;
             }
         case "v0.16":
             // current version
             break;
         default:
             // no provision for this version, should not happen
             print "Trip::updateTables({$dataVersion}): don't know this version.\n";
             return false;
     }
     return true;
 }