本文整理汇总了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;
}
示例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;
}
示例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');
}
}