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


PHP Installer::getDBTypes方法代碼示例

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


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

示例1: execute

 /**
  * @return string|null When string, "skip" or "continue"
  */
 public function execute()
 {
     if ($this->getVar('_ExistingDBSettings')) {
         return 'skip';
     }
     $r = $this->parent->request;
     if ($r->wasPosted()) {
         $status = $this->submit();
         if ($status->isGood()) {
             $this->setVar('_UpgradeDone', false);
             return 'continue';
         } else {
             $this->parent->showStatusBox($status);
         }
     }
     $this->startForm();
     $types = "<ul class=\"config-settings-block\">\n";
     $settings = '';
     $defaultType = $this->getVar('wgDBtype');
     // Messages: config-dbsupport-mysql, config-dbsupport-postgres, config-dbsupport-oracle,
     // config-dbsupport-sqlite, config-dbsupport-mssql
     $dbSupport = '';
     foreach (Installer::getDBTypes() as $type) {
         $dbSupport .= wfMessage("config-dbsupport-{$type}")->plain() . "\n";
     }
     $this->addHTML($this->parent->getInfoBox(wfMessage('config-support-info', trim($dbSupport))->text()));
     // It's possible that the library for the default DB type is not compiled in.
     // In that case, instead select the first supported DB type in the list.
     $compiledDBs = $this->parent->getCompiledDBs();
     if (!in_array($defaultType, $compiledDBs)) {
         $defaultType = $compiledDBs[0];
     }
     foreach ($compiledDBs as $type) {
         $installer = $this->parent->getDBInstaller($type);
         $types .= '<li>' . Xml::radioLabel($installer->getReadableName(), 'DBType', $type, "DBType_{$type}", $type == $defaultType, array('class' => 'dbRadio', 'rel' => "DB_wrapper_{$type}")) . "</li>\n";
         // Messages: config-header-mysql, config-header-postgres, config-header-oracle,
         // config-header-sqlite
         $settings .= Html::openElement('div', array('id' => 'DB_wrapper_' . $type, 'class' => 'dbWrapper')) . Html::element('h3', array(), wfMessage('config-header-' . $type)->text()) . $installer->getConnectForm() . "</div>\n";
     }
     $types .= "</ul><br style=\"clear: left\"/>\n";
     $this->addHTML($this->parent->label('config-db-type', false, $types) . $settings);
     $this->endForm();
     return null;
 }
開發者ID:Kaph-Noir,項目名稱:mediawiki,代碼行數:47,代碼來源:WebInstallerDBConnect.php

示例2: handleExistingUpgrade

 /**
  * Initiate an upgrade of the existing database
  *
  * @param mixed[] $vars Variables from LocalSettings.php
  *
  * @return Status
  */
 protected function handleExistingUpgrade($vars)
 {
     // Check $wgDBtype
     if (!isset($vars['wgDBtype']) || !in_array($vars['wgDBtype'], Installer::getDBTypes())) {
         return Status::newFatal('config-localsettings-connection-error', '');
     }
     // Set the relevant variables from LocalSettings.php
     $requiredVars = ['wgDBtype'];
     $status = $this->importVariables($requiredVars, $vars);
     $installer = $this->parent->getDBInstaller();
     $status->merge($this->importVariables($installer->getGlobalNames(), $vars));
     if (!$status->isOK()) {
         return $status;
     }
     if (isset($vars['wgDBadminuser'])) {
         $this->setVar('_InstallUser', $vars['wgDBadminuser']);
     } else {
         $this->setVar('_InstallUser', $vars['wgDBuser']);
     }
     if (isset($vars['wgDBadminpassword'])) {
         $this->setVar('_InstallPassword', $vars['wgDBadminpassword']);
     } else {
         $this->setVar('_InstallPassword', $vars['wgDBpassword']);
     }
     // Test the database connection
     $status = $installer->getConnection();
     if (!$status->isOK()) {
         // Adjust the error message to explain things correctly
         $status->replaceMessage('config-connection-error', 'config-localsettings-connection-error');
         return $status;
     }
     // All good
     $this->setVar('_ExistingDBSettings', true);
     // Copy $wgAuthenticationTokenVersion too, if it exists
     $this->setVar('wgAuthenticationTokenVersion', isset($vars['wgAuthenticationTokenVersion']) ? $vars['wgAuthenticationTokenVersion'] : null);
     return $status;
 }
開發者ID:claudinec,項目名稱:galan-wiki,代碼行數:44,代碼來源:WebInstallerExistingWiki.php

示例3: newForDB

 /**
  * @param DatabaseBase $db
  * @param bool $shared
  * @param Maintenance $maintenance
  *
  * @throws MWException
  * @return DatabaseUpdater
  */
 public static function newForDB(&$db, $shared = false, $maintenance = null)
 {
     $type = $db->getType();
     if (in_array($type, Installer::getDBTypes())) {
         $class = ucfirst($type) . 'Updater';
         return new $class($db, $shared, $maintenance);
     } else {
         throw new MWException(__METHOD__ . ' called for unsupported $wgDBtype');
     }
 }
開發者ID:whysasse,項目名稱:kmwiki,代碼行數:18,代碼來源:DatabaseUpdater.php


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