当前位置: 首页>>代码示例>>PHP>>正文


PHP Database::createInstance方法代码示例

本文整理汇总了PHP中Fisharebest\Webtrees\Database::createInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Database::createInstance方法的具体用法?PHP Database::createInstance怎么用?PHP Database::createInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Fisharebest\Webtrees\Database的用法示例。


在下文中一共展示了Database::createInstance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: catch

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']);
$db_version_ok = false;
try {
    Database::createInstance($_POST['dbhost'], $_POST['dbport'], '', $_POST['dbuser'], $_POST['dbpass']);
    Database::exec("SET NAMES 'utf8'");
    $row = Database::prepare("SHOW VARIABLES LIKE 'VERSION'")->fetchOneRow();
    if (version_compare($row->value, WT_REQUIRED_MYSQL_VERSION, '<')) {
        echo '<p class="bad">', 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) {
    Database::disconnect();
    if ($_POST['dbuser']) {
        // If we’ve supplied a login, then show the error
        echo '<p class="bad">', I18N::translate('Unable to connect using these settings.  Your server gave the following error.'), '</p>', '<pre>', $ex->getMessage(), '</pre>', '<p class="bad">', I18N::translate('Check the settings and try again.'), '</p>';
    }
}
if (empty($_POST['dbuser']) || !Database::isConnected() || !$db_version_ok) {
开发者ID:tunandras,项目名称:webtrees,代码行数:31,代码来源:setup.php

示例2: header

} else {
    // No config file. Set one up.
    header('Location: ' . WT_BASE_URL . 'setup.php');
    exit;
}
// What is the remote client's IP address
if (Filter::server('HTTP_CLIENT_IP') !== null) {
    define('WT_CLIENT_IP', Filter::server('HTTP_CLIENT_IP'));
} elseif (Filter::server('HTTP_X_FORWARDED_FOR') !== null) {
    define('WT_CLIENT_IP', Filter::server('HTTP_X_FORWARDED_FOR'));
} else {
    define('WT_CLIENT_IP', Filter::server('REMOTE_ADDR', WT_REGEX_IPV4, '127.0.0.1'));
}
// Connect to the database
try {
    Database::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
    Database::exec("SET NAMES 'utf8' COLLATE 'utf8_unicode_ci', SQL_BIG_SELECTS=1");
    // Update the database schema
    Database::updateSchema('\\Fisharebest\\Webtrees\\Schema', 'WT_SCHEMA_VERSION', WT_SCHEMA_VERSION);
} catch (PDOException $ex) {
    FlashMessages::addMessage($ex->getMessage(), 'danger');
    header('Location: ' . WT_BASE_URL . 'site-unavailable.php');
    throw $ex;
}
// The config.ini.php file must always be in a fixed location.
// Other user files can be stored elsewhere...
define('WT_DATA_DIR', realpath(Site::getPreference('INDEX_DIRECTORY') ? Site::getPreference('INDEX_DIRECTORY') : 'data') . DIRECTORY_SEPARATOR);
// If we have a preferred URL (e.g. www.example.com instead of www.isp.com/~example), then redirect to it.
开发者ID:tunandras,项目名称:webtrees,代码行数:31,代码来源:session.php


注:本文中的Fisharebest\Webtrees\Database::createInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。