Example #1
0
 /**
  * Executes an update.
  *
  * This function also checks if the update hasn't already been inserted in the database.
  *
  * Checks if it's sql or php. If it's PHP the file only gets included.
  *
  * If $this->simulate == true, this function does nothing.
  *
  * @param DatabaseUpdate $update
  */
 protected function executeUpdate($update)
 {
     if ($update->number !== 0 && $this->updateIsDeprecated($update)) {
         return;
     }
     $this->executedUpdates[] = $update;
     if ($this->simulate) {
         return;
     }
     if ($update->type === 'sql') {
         try {
             $this->db->multiQuery(file_get_contents($this->updatesPath . $update->filename));
         } catch (DatabaseQueryException $e) {
             throw new DatabaseUpdaterException('Error in file: ' . $update->filename . "\n" . $e->getMessage());
         }
     } else {
         include $this->updatesPath . $update->filename;
     }
     if ($update->number != 0) {
         $this->versionDao->get()->set('number', $update->number)->set('username', $update->username)->set('branch', $update->branch)->save();
     }
 }