當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Misc::getDirFiles方法代碼示例

本文整理匯總了PHP中nzedb\utility\Misc::getDirFiles方法的典型用法代碼示例。如果您正苦於以下問題:PHP Misc::getDirFiles方法的具體用法?PHP Misc::getDirFiles怎麽用?PHP Misc::getDirFiles使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在nzedb\utility\Misc的用法示例。


在下文中一共展示了Misc::getDirFiles方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: checkSQLFileLatest

 /**
  * Checks the numeric value from the last SQL patch file, updating the versions file if desired.
  *
  * @param bool $update	Whether to update the versions file.
  *
  * @return bool|int	False if there is a problem, otherwise the number from the last patch file.
  */
 public function checkSQLFileLatest($update = true)
 {
     $options = ['data' => nZEDb_RES . 'db' . DS . 'schema' . DS . 'data' . DS, 'ext' => 'sql', 'path' => nZEDb_RES . 'db' . DS . 'patches' . DS . 'mysql', 'regex' => '#^' . Misc::PATH_REGEX . '(?P<patch>\\d{4})~(?P<table>\\w+)\\.sql$#', 'safe' => true];
     $files = Misc::getDirFiles($options);
     natsort($files);
     $last = preg_match($options['regex'], end($files), $matches) ? (int) $matches['patch'] : false;
     if ($update) {
         if ($last !== false && $this->_vers->sql->file->__toString() != $last) {
             echo $this->out->primary("Updating latest patch file to " . $last);
             $this->_vers->sql->file = $last;
             $this->_changes |= self::UPDATED_SQL_FILE_LAST;
         }
         if ($this->_vers->sql->file->__toString() != $last) {
             $this->_vers->sql->file = $last;
             $this->_changes |= self::UPDATED_SQL_DB_PATCH;
         }
     }
     return $last;
 }
開發者ID:zetas,項目名稱:nZEDb,代碼行數:26,代碼來源:Versions.php

示例2: processPatches

 public function processPatches(array $options = [])
 {
     $patched = 0;
     $defaults = ['data' => nZEDb_RES . 'db' . DS . 'schema' . DS . 'data' . DS, 'ext' => 'sql', 'path' => nZEDb_RES . 'db' . DS . 'patches' . DS . $this->_DbSystem, 'regex' => '#^' . Misc::PATH_REGEX . '(?P<patch>\\d{4})~(?P<table>\\w+)\\.sql$#', 'safe' => true];
     $options += $defaults;
     $currentVersion = $this->settings->getSetting(['setting' => 'sqlpatch']);
     if (!is_numeric($currentVersion)) {
         exit("Bad sqlpatch value: '{$currentVersion}'\n");
     }
     $files = empty($options['files']) ? Misc::getDirFiles($options) : $options['files'];
     if (count($files)) {
         natsort($files);
         $local = $this->pdo->isLocalDb() ? '' : 'LOCAL ';
         $data = $options['data'];
         echo $this->log->primary('Looking for unprocessed patches...');
         foreach ($files as $file) {
             $setPatch = false;
             $fp = fopen($file, 'r');
             $patch = fread($fp, filesize($file));
             if (preg_match($options['regex'], str_replace('\\', '/', $file), $matches)) {
                 $patch = (int) $matches['patch'];
                 $setPatch = true;
             } else {
                 if (preg_match('/UPDATE `?site`? SET `?value`? = \'?(?P<patch>\\d+)\'? WHERE `?setting`? = \'sqlpatch\'/i', $patch, $matches)) {
                     $patch = (int) $matches['patch'];
                 } else {
                     throw new \RuntimeException("No patch information available, stopping!!");
                 }
             }
             if ($patch > $currentVersion) {
                 echo $this->log->header('Processing patch file: ' . $file);
                 if ($options['safe'] && !$this->backedUp) {
                     $this->_backupDb();
                 }
                 $this->splitSQL($file, ['local' => $local, 'data' => $data]);
                 if ($setPatch) {
                     $this->pdo->queryExec("UPDATE settings SET value = '{$patch}' WHERE setting = 'sqlpatch';");
                 }
                 $patched++;
             }
         }
     } else {
         exit($this->log->error("\nHave you changed the path to the patches folder, or do you have the right permissions?\n"));
     }
     if ($patched === 0) {
         echo $this->log->info("Nothing to patch, you are already on version {$currentVersion}");
     }
     return $patched;
 }
開發者ID:kaibosh,項目名稱:nZEDb,代碼行數:49,代碼來源:DbUpdate.php


注:本文中的nzedb\utility\Misc::getDirFiles方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。