本文整理汇总了PHP中WT_DB::disconnect方法的典型用法代码示例。如果您正苦于以下问题:PHP WT_DB::disconnect方法的具体用法?PHP WT_DB::disconnect怎么用?PHP WT_DB::disconnect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WT_DB
的用法示例。
在下文中一共展示了WT_DB::disconnect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: define
if (!isset($_POST['tblpfx'])) {
$_POST['tblpfx'] = 'wt_';
}
define('WT_TBLPREFIX', $_POST['tblpfx']);
try {
$db_version_ok = false;
WT_DB::createInstance($_POST['dbhost'], $_POST['dbport'], '', $_POST['dbuser'], $_POST['dbpass']);
WT_DB::exec("SET NAMES 'utf8'");
$row = WT_DB::prepare("SHOW VARIABLES LIKE 'VERSION'")->fetchOneRow();
if (version_compare($row->value, WT_REQUIRED_MYSQL_VERSION, '<')) {
echo '<p class="bad">', WT_I18N::translate('This database is only running MySQL version %s. You cannot install webtrees here.', $row->value), '</p>';
} else {
$db_version_ok = true;
}
} catch (PDOException $ex) {
WT_DB::disconnect();
if ($_POST['dbuser']) {
// If we’ve supplied a login, then show the error
echo '<p class="bad">', WT_I18N::translate('Unable to connect using these settings. Your server gave the following error.'), '</p>', '<pre>', $ex->getMessage(), '</pre>', '<p class="bad">', WT_I18N::translate('Check the settings and try again.'), '</p>';
}
}
if (empty($_POST['dbuser']) || !WT_DB::isConnected() || !$db_version_ok) {
echo '<h2>', WT_I18N::translate('Connection to database server'), '</h2>', '<p>', WT_I18N::translate('<b>webtrees</b> needs a MySQL database, version %s or later.', WT_REQUIRED_MYSQL_VERSION), '</p>', '<p>', WT_I18N::translate('Your server’s administrator will provide you with the connection details.'), '</p>', '<fieldset><legend>', WT_I18N::translate('Database connection'), '</legend>', '<table border="0"><tr><td>', WT_I18N::translate('Server name'), '</td><td>', '<input type="text" name="dbhost" value="', WT_Filter::escapeHtml($_POST['dbhost']), '" dir="ltr"></td><td>', WT_I18N::translate('Most sites are configured to use localhost. This means that your database runs on the same computer as your web server.'), '</td></tr><tr><td>', WT_I18N::translate('Port number'), '</td><td>', '<input type="text" name="dbport" value="', WT_Filter::escapeHtml($_POST['dbport']), '"></td><td>', WT_I18N::translate('Most sites are configured to use the default value of 3306.'), '</td></tr><tr><td>', WT_I18N::translate('Database user account'), '</td><td>', '<input type="text" name="dbuser" value="', WT_Filter::escapeHtml($_POST['dbuser']), '" autofocus></td><td>', WT_I18N::translate('This is case sensitive.'), '</td></tr><tr><td>', WT_I18N::translate('Database password'), '</td><td>', '<input type="password" name="dbpass" value="', WT_Filter::escapeHtml($_POST['dbpass']), '"></td><td>', WT_I18N::translate('This is case sensitive.'), '</td></tr><tr><td>', '</td></tr></table>', '</fieldset>', '<br><hr><input type="submit" id="btncontinue" value="', WT_I18N::translate('continue'), '">', '</form>', '</body></html>';
exit;
} else {
// Copy these values through to the next step
echo '<input type="hidden" name="dbhost" value="', WT_Filter::escapeHtml($_POST['dbhost']), '">';
echo '<input type="hidden" name="dbport" value="', WT_Filter::escapeHtml($_POST['dbport']), '">';
echo '<input type="hidden" name="dbuser" value="', WT_Filter::escapeHtml($_POST['dbuser']), '">';
echo '<input type="hidden" name="dbpass" value="', WT_Filter::escapeHtml($_POST['dbpass']), '">';
}