当前位置: 首页>>代码示例>>PHP>>正文


PHP Phprojekt::compareVersion方法代码示例

本文整理汇总了PHP中Phprojekt::compareVersion方法的典型用法代码示例。如果您正苦于以下问题:PHP Phprojekt::compareVersion方法的具体用法?PHP Phprojekt::compareVersion怎么用?PHP Phprojekt::compareVersion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Phprojekt的用法示例。


在下文中一共展示了Phprojekt::compareVersion方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getModulesNeedingUpgrade

 /**
  * Retrieve the modules needing upgrades.
  *
  * The return value will be in following format:
  *  array(
  *      ModuleName => array(
  *          'from'      => string: The current version in the db.
  *          'to'        => string: The current code version of the module.
  *          'migration' => Phprojekt_Migration_Abstract: The module's
  *                                                       migration object.
  *      )
  *  )
  *
  * @return array See description
  */
 public function getModulesNeedingUpgrade()
 {
     if (!is_null($this->_modulesNeedingUpgrade)) {
         return $this->_modulesNeedingUpgrade;
     }
     $db = Phprojekt::getInstance()->getDb();
     $moduleVersions = $db->fetchAssoc('SELECT LOWER(name), version FROM module');
     $return = array();
     foreach ($this->_migrations as $module => $migration) {
         $module = strtolower($module);
         $codeVersion = $migration->getCurrentModuleVersion();
         if (array_key_exists($module, $moduleVersions)) {
             // The module is already installed and we are upgrading.
             $moduleVersion = $moduleVersions[$module]['version'];
             $compare = Phprojekt::compareVersion($moduleVersion, $codeVersion);
             if ($compare > 0) {
                 // The current db version is higher than the code version.
                 // TODO: Handle this.
             } else {
                 if ($compare < 0) {
                     $return[$module] = array('from' => $moduleVersion, 'to' => $codeVersion, 'migration' => $migration);
                 }
             }
         } else {
             // The module is new. Add it to the list
             $return[$module] = array('from' => null, 'to' => $codeVersion, 'migration' => $migration);
         }
     }
     $this->_modulesNeedingUpgrade = $return;
     return $return;
 }
开发者ID:RainyBlueSky,项目名称:PHProjekt,代码行数:46,代码来源:Migration.php

示例2: testCompareVersion

 public function testCompareVersion()
 {
     $this->assertGreaterThan(0, Phprojekt::compareVersion("6.0.10", Phprojekt::getVersion()));
     $this->assertGreaterThan(0, Phprojekt::compareVersion("6.0.1", "6.0.0"));
     $this->assertLessThan(0, Phprojekt::compareVersion("6.0.1", "6.1.0"));
     $this->assertGreaterThan(0, Phprojekt::compareVersion("6.0.1-RC2", "6.0.1-RC1"));
     $this->assertLessThan(0, Phprojekt::compareVersion("6.0.0-RC1", "6.0.0"));
     $this->assertEquals(0, Phprojekt::compareVersion("6.0.0-RC1", "6.0.0-RC1"));
     $this->assertEquals(0, Phprojekt::compareVersion("6.0.1", "6.0.1"));
 }
开发者ID:penSecIT,项目名称:PHProjekt,代码行数:10,代码来源:PhprojektTest.php

示例3: upgrade

 /**
  * Upgrade to the latest version.
  *
  * @param String $currentVersion Phprojekt version string indicating our
  *                               current version
  * @param Zend_Db_Adapter_Abstract $db The database to use
  *
  * @return void
  * @throws Exception On Errors
  */
 public function upgrade($currentVersion, Zend_Db_Adapter_Abstract $db)
 {
     $this->_db = $db;
     if (Phprojekt::compareVersion($currentVersion, '6.1.5') < 0) {
         $this->_renameFilemanagersWithSameTitle();
         $this->parseDbFile('Filemanager');
         Phprojekt::getInstance()->getCache()->clean(Zend_Cache::CLEANING_MODE_ALL);
         $this->_renameFilesWithSameName();
     }
 }
开发者ID:RainyBlueSky,项目名称:PHProjekt,代码行数:20,代码来源:Migration.php

示例4: patchOldModuleGrids

 private function patchOldModuleGrids()
 {
     $applicationPath = Phprojekt::getInstance()->getConfig()->applicationPath;
     $moduleDirs = scandir($applicationPath);
     foreach ($moduleDirs as $moduleName) {
         if ($moduleName != "." && $moduleName != "..") {
             $select = $this->_db->select()->from("module", array("version", "id"))->where("name = ?", $moduleName)->limit(1);
             $row = $this->_db->fetchRow($select);
             if ($row !== false && Phprojekt::compareVersion($row["version"], "6.2.1") < 0) {
                 $this->patchOldModuleGrid($moduleName);
                 $this->_db->update("module", array("version" => "6.2.1"), $this->_db->quoteInto("id = ?", $row["id"]));
             }
         }
     }
 }
开发者ID:RainyBlueSky,项目名称:PHProjekt,代码行数:15,代码来源:Migration.php

示例5: _getVersionsForProcess

 /**
  * Delete all the version higher than the current one
  * and the version lower than the current module version.
  *
  * @param string $module Current module of the data.
  * @param array  $data   Array with all the version and data for parse.
  *
  * @return array Array with only the correct versions.
  */
 private function _getVersionsForProcess($module, $data)
 {
     $current = Phprojekt::getVersion();
     $moduleVersion = $this->_getModuleVersion($module);
     foreach (array_keys($data) as $version) {
         if (Phprojekt::compareVersion($moduleVersion, $version) > 0 || Phprojekt::compareVersion($current, $version) < 0) {
             unset($data[$version]);
         }
     }
     return $data;
 }
开发者ID:joerch,项目名称:PHProjekt,代码行数:20,代码来源:DbParser.php


注:本文中的Phprojekt::compareVersion方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。