本文整理汇总了PHP中WT_DB::createInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP WT_DB::createInstance方法的具体用法?PHP WT_DB::createInstance怎么用?PHP WT_DB::createInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WT_DB
的用法示例。
在下文中一共展示了WT_DB::createInstance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: header
}
// Down for maintenance?
if (file_exists(WT_ROOT . 'data/offline.txt')) {
header('Location: ' . WT_SERVER_NAME . WT_SCRIPT_PATH . 'site-offline.php');
exit;
}
} else {
// No config file. Set one up.
header('Location: ' . WT_SERVER_NAME . WT_SCRIPT_PATH . 'setup.php');
exit;
}
$WT_REQUEST = new Zend_Controller_Request_Http();
require WT_ROOT . 'includes/authentication.php';
// Connect to the database
try {
WT_DB::createInstance($dbconfig['dbhost'], $dbconfig['dbport'], $dbconfig['dbname'], $dbconfig['dbuser'], $dbconfig['dbpass']);
define('WT_TBLPREFIX', $dbconfig['tblpfx']);
unset($dbconfig);
// Some of the FAMILY JOIN HUSBAND JOIN WIFE queries can excede the MAX_JOIN_SIZE setting
WT_DB::exec("SET NAMES 'utf8' COLLATE 'utf8_unicode_ci', SQL_BIG_SELECTS=1");
try {
WT_DB::updateSchema(WT_ROOT . 'includes/db_schema/', 'WT_SCHEMA_VERSION', WT_SCHEMA_VERSION);
} catch (PDOException $ex) {
// The schema update scripts should never fail. If they do, there is no clean recovery.
die($ex);
}
} catch (PDOException $ex) {
header('Location: ' . WT_SERVER_NAME . WT_SCRIPT_PATH . 'site-unavailable.php');
exit;
}
// The config.ini.php file must always be in a fixed location.
示例2: define
if (!isset($_POST['dbuser'])) {
$_POST['dbuser'] = '';
}
if (!isset($_POST['dbpass'])) {
$_POST['dbpass'] = '';
}
if (!isset($_POST['dbname'])) {
$_POST['dbname'] = '';
}
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) {