本文整理汇总了PHP中DBConnection::createMainConfig方法的典型用法代码示例。如果您正苦于以下问题:PHP DBConnection::createMainConfig方法的具体用法?PHP DBConnection::createMainConfig怎么用?PHP DBConnection::createMainConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBConnection
的用法示例。
在下文中一共展示了DBConnection::createMainConfig方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update1
function update1($DBname)
{
$host = $_SESSION['db_access']['host'];
$user = $_SESSION['db_access']['user'];
$password = $_SESSION['db_access']['password'];
if (DBConnection::createMainConfig($host, $user, $password, $DBname) && !empty($DBname)) {
$from_install = true;
include_once GLPI_ROOT . "/install/update.php";
} else {
// can't create config_db file
_e("Can't create the database connection file, please verify file permissions.");
echo "<h3>" . __('Do you want to continue?') . "</h3>";
echo "<form action='install.php' method='post'>";
echo "<input type='hidden' name='update' value='yes'>";
echo "<p class='submit'><input type='hidden' name='install' value='Etape_0'>";
echo "<input type='submit' name='submit' class='submit' value=\"" . __('Continue') . "\">";
echo "</p>";
Html::closeForm();
}
}
示例2: die
if (file_exists(GLPI_CONFIG_DIR . '/config_db.php') && !isset($args['force'])) {
die("Already installed (see --force option)\n");
}
$_SESSION = ['glpilanguage' => isset($args['lang']) ? $args['lang'] : 'en_GB'];
Toolbox::setDebugMode(Session::DEBUG_MODE, 0, 0, 1);
echo "Connect to the DB...\n";
//Check if the port is in url
$hostport = explode(':', $args['host']);
if (count($hostport) < 2) {
$link = new mysqli($hostport[0], $args['user'], $args['pass']);
} else {
$link = new mysqli($hostport[0], $args['user'], $args['pass'], '', $hostport[1]);
}
if (!$link || mysqli_connect_error()) {
die("DB connection failed\n");
}
$args['db'] = $link->real_escape_string($args['db']);
echo "Create the DB...\n";
if (!$link->query("CREATE DATABASE IF NOT EXISTS `" . $args['db'] . "`")) {
die("Can't create the DB\n");
}
if (!$link->select_db($args['db'])) {
die("Can't select the DB\n");
}
echo "Save configuration file...\n";
if (!DBConnection::createMainConfig($args['host'], $args['user'], $args['pass'], $args['db'])) {
die("Can't write configuration file\n");
}
echo "Load default schema...\n";
Toolbox::createSchema($_SESSION['glpilanguage']);
echo "Done\n";