Esempio n. 1
0
 /**
  * Primary task entry point
  *
  * @param array $args The current supplied options.
  */
 public function execute($args)
 {
     $output = "Started: " . date('Y-m-d g:ia T') . "\n\n";
     $output .= "[db:version]: \n";
     if (!$this->_adapter->table_exists($this->_adapter->get_schema_version_table_name())) {
         //it doesnt exist, create it
         $output .= "\tSchema version table (" . $this->_adapter->get_schema_version_table_name() . ") does not exist. Do you need to run 'db:setup'?";
     } else {
         //it exists, read the version from it
         // We only want one row but we cannot assume that we are using MySQL and use a LIMIT statement
         // as it is not part of the SQL standard. Thus we have to select all rows and use PHP to return
         // the record we need
         $versions_nested = $this->_adapter->select_all(sprintf("SELECT version FROM %s", $this->_adapter->get_schema_version_table_name()));
         $versions = array();
         foreach ($versions_nested as $v) {
             $versions[] = $v['version'];
         }
         $num_versions = count($versions);
         if ($num_versions > 0) {
             sort($versions);
             //sorts lowest-to-highest (ascending)
             $version = (string) $versions[$num_versions - 1];
             $output .= sprintf("\tCurrent version: %s", $version);
         } else {
             $output .= sprintf("\tNo migrations have been executed.");
         }
     }
     $output .= "\n\nFinished: " . date('Y-m-d g:ia T') . "\n\n";
     return $output;
 }
 /**
  * Query the database and return a list of migration versions that *have* been executed
  *
  * @return array
  */
 private function executed_migrations()
 {
     $query_sql = sprintf('SELECT version FROM %s', RUCKUSING_TS_SCHEMA_TBL_NAME);
     $versions = $this->_adapter->select_all($query_sql);
     $executed = array();
     foreach ($versions as $v) {
         $executed[] = $v['version'];
     }
     sort($executed);
     return $executed;
 }
Esempio n. 3
0
 /**
  * Query the database and return a list of migration versions that *have* been executed
  *
  * @return array
  */
 private function executed_migrations()
 {
     $query_sql = sprintf('SELECT version FROM %s', $this->_adapter->get_schema_version_table_name());
     $versions = $this->_adapter->select_all($query_sql);
     $executed = array();
     foreach ($versions as $v) {
         $executed[] = $v['version'];
     }
     sort($executed);
     return $executed;
 }
Esempio n. 4
0
 /**
  * Select all query
  *
  * @param string $sql the query to run
  *
  * @return array
  */
 public function select_all($sql)
 {
     return $this->_adapter->select_all($sql);
 }