Example #1
0
 /**
  * Upgrades table.
  *
  * @global object $wpdb Wordpress DB class
  * @global string $table_prefix Wordpress table prefix
  * @param string $path base path to folder where the install folder is located with trailing slash
  * @param string $file table file name
  */
 function upgrade_table($path, $file)
 {
     global $wpdb, $table_prefix;
     $file_path = $path . "/" . $file;
     $table_name = $table_prefix . substr($file, 0, strlen($file) - 4);
     $columns = $wpdb->get_results(sprintf("SHOW COLUMNS FROM %s", $table_name));
     $fc = file($file_path);
     $after = '';
     foreach ($fc as $f) {
         $f = trim($f);
         if (substr($f, 0, 1) == "`") {
             $column = substr($f, 1);
             $column = substr($column, 0, strpos($column, "`"));
             if (!gdDBInstallGDPT::check_column($columns, $column)) {
                 gdDBInstallGDPT::add_column($table_name, $f, $after);
             }
             $after = $column;
         }
     }
 }