Пример #1
0
 /**
  * Return the max version number from the DB,
  * or "0" in the case of no versions available.
  * We must use strings because our date/timestamp
  * when treated as an integer would cause overflow.
  *
  * @return string
  */
 public function getMaxVersion()
 {
     // 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->selectAll(sprintf('SELECT version FROM %s', $this->_adapter->Identifier(PHIGRATE_TS_SCHEMA_TBL_NAME)));
     $versions = array();
     foreach ($versions_nested as $v) {
         $versions[] = $v['version'];
     }
     $num_versions = count($versions);
     $version = null;
     if ($num_versions) {
         sort($versions);
         //sorts lowest-to-highest (ascending)
         $version = (string) $versions[$num_versions - 1];
     }
     return $version;
 }