Example #1
0
 function get_db_versions($limit = 100, $only_needs_upgrade = TRUE)
 {
     $mhi_db = Kohana::config('database.default');
     $table_prefix = $mhi_db['table_prefix'];
     $mhi_db_name = $mhi_db['connection']['database'];
     $dbs = Mhi_Site_Database_Model::get_all_db_details();
     // Switch to new DB for a moment
     $array = array();
     $settings = ORM::factory('settings', 1);
     $current_version = $settings->db_version;
     $i = 0;
     foreach ($dbs as $db) {
         if ($i >= $limit) {
             break;
         }
         mysql_query('USE ' . $db . ';');
         // START: Everything that happens in the deployment DB happens below
         $settings = ORM::factory('settings', 1);
         if ($only_needs_upgrade == FALSE or $settings->db_version != $current_version) {
             $array[$db] = $settings->db_version;
             $i++;
         }
     }
     // END: Everything that happens in the deployment DB happens above
     //Switch back to our db, otherwise we would be running off some other deployments DB and that wouldn't work
     mysql_query('USE ' . $mhi_db_name);
     return $array;
 }
Example #2
0
 function get_db_versions()
 {
     $mhi_db = Kohana::config('database.default');
     $table_prefix = $mhi_db['table_prefix'];
     $mhi_db_name = $mhi_db['connection']['database'];
     $dbs = Mhi_Site_Database_Model::get_all_db_details();
     // Switch to new DB for a moment
     $array = array();
     foreach ($dbs as $db) {
         mysql_query('USE ' . $db . ';');
         // START: Everything that happens in the deployment DB happens below
         $settings = ORM::factory('settings', 1);
         $array[$db] = $settings->db_version;
     }
     // END: Everything that happens in the deployment DB happens above
     //Switch back to our db, otherwise we would be running off some other deployments DB and that wouldn't work
     mysql_query('USE ' . $mhi_db_name);
     return $array;
 }