コード例 #1
0
ファイル: UpgradeHandler.php プロジェクト: mheydt/scalr
 /**
  * Getches statuses of the previous updates for specified database service
  * from container
  *
  * @param   string $service  Service name for database connection in DI container
  */
 private function fetchMysqlStatusBefore($service = 'adodb')
 {
     $db = \Scalr::getContainer()->{$service};
     //Loads performed updates of MYSQL type
     $rs = $db->Execute("\n            SELECT LOWER(HEX(u.`uuid`)) `uuid`, u.`released`, u.`appears`, u.`applied`, u.`status`, LOWER(HEX(u.`hash`)) `hash`\n            FROM `" . self::DB_TABLE_UPGRADES . "` u\n        ");
     while ($rec = $rs->FetchRow()) {
         $entity = new MysqlUpgradeEntity();
         $entity->load($rec);
         $this->stateBefore[$rec['uuid']] = $entity;
         if (isset($entity->appears) && $this->maxDate < $entity->appears) {
             $this->maxDate = $entity->appears;
         }
     }
 }
コード例 #2
0
ファイル: UpgradeHandler.php プロジェクト: recipe/scalr
 /**
  * Fetches statuses of the previous updates
  */
 private function fetchStatusBefore()
 {
     $this->stateBefore = new \ArrayObject();
     //Loads performed updates of MYSQL type
     $rs = $this->db->Execute("\n            SELECT LOWER(HEX(u.`uuid`)) `uuid`, u.`released`, u.`appears`, u.`applied`, u.`status`, LOWER(HEX(u.`hash`)) `hash`\n            FROM `" . self::DB_TABLE_UPGRADES . "` u\n        ");
     while ($rec = $rs->FetchRow()) {
         $entity = new MysqlUpgradeEntity();
         $entity->load($rec);
         $this->stateBefore[$rec['uuid']] = $entity;
         if (isset($entity->appears) && $this->maxDate < $entity->appears) {
             $this->maxDate = $entity->appears;
         }
     }
     //Loads updates of FileSystem type
     self::checkFilesystemStorage();
     //Loads performed updates of Filesystem type
     foreach (new FilesystemStorageIterator(self::FS_STORAGE_PATH) as $fileInfo) {
         /* @var $fileInfo \SplFileInfo */
         if (!$fileInfo->isReadable()) {
             throw new Exception\UpgradeException(sprintf('Could not read from file "%s". Lack of access permissions.', $fileInfo->getFilename()));
         }
         $entity = new FilesystemUpgradeEntity();
         $obj = unserialize(file_get_contents($fileInfo->getPathname()));
         if (!is_object($obj)) {
             throw new Exception\UpgradeException(sprintf('There was error while trying to load record from filesystem storage "%s". Object is expected, %s given', $fileInfo->getPathname(), gettype($obj)));
         }
         $entity->load($obj);
         $this->stateBefore[$entity->uuid] = $entity;
         if (isset($entity->appears) && $this->maxDate < $entity->appears) {
             $this->maxDate = $entity->appears;
         }
         unset($obj);
     }
 }