本文整理汇总了PHP中mysqli::change_user方法的典型用法代码示例。如果您正苦于以下问题:PHP mysqli::change_user方法的具体用法?PHP mysqli::change_user怎么用?PHP mysqli::change_user使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mysqli
的用法示例。
在下文中一共展示了mysqli::change_user方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mysqli
<?php
require '../classes/AutoLoad.php';
date_default_timezone_set('Europe/Madrid');
$mysql = new mysqli(Constan::SERVER, Constan::DBUSER, Constan::DBPASSWORD);
$res = $mysql->query(FileManager::read('sql/sql.sql'));
$mysql->change_user(Constan::DBUSER, Constan::DBPASSWORD, Constan::DATABASE);
$ms = scandir('../modules');
foreach ($ms as $key => $value) {
if ($value !== '.' && $value !== '..' && $value !== 'index.php') {
if (is_dir('../modules/' . $value)) {
$files = scandir('../modules/' . $value . '/sql');
foreach ($files as $file) {
if ($file !== '.' && $file !== '..') {
$mysql->query(FileManager::read('../modules/' . $value . '/sql/' . $file));
}
}
}
}
}
$mysql->close();
header('Location:../modules/');
示例2: changeDatabase
/**
* Change currently selected database.
* @param string $databaseName New database name.
* @return boolean Returns <b>TRUE</b> on success or <b>FALSE</b> on failure.
*/
public function changeDatabase($databaseName)
{
if (parent::change_user($this->userName, $this->userPassword, $databaseName)) {
$this->databaseName = $databaseName;
return TRUE;
}
return FALSE;
}
示例3: elseif
} elseif (strlen($_POST["DatabaseWriterHost"]) > 64) {
$pageErrors[] = "Database Writer Connectivity Host must not be greater than 64 characters.";
}
if ($_POST["DatabaseWriterPass"] == "") {
$pageErrors[] = "Database Writer Password must not be empty.";
} elseif (strlen($_POST["DatabaseWriterPass"]) > 20) {
$pageErrors[] = "Database Writer Password must not be greater than 20 characters.";
}
if (count($pageErrors) == 0) {
$mySQLiConn = new mysqli("p:" . $mysqlHost, $mysqlAdminUser, $mysqlAdminPass, "mysql", $mysqlPort);
if (!$mySQLiConn->connect_error) {
// -- create database
$createDatabase = "CREATE DATABASE `" . $databaseName . "` DEFAULT CHARACTER SET utf8 COLLATE utf8_bin";
if ($mySQLiConn->query($createDatabase)) {
$pageSuccess[] = "Successfully created database `" . $databaseName . "`.";
$mySQLiConn->change_user($mysqlAdminUser, $mysqlAdminPass, $databaseName);
if (!$mySQLiConn->connect_error) {
// -- create table `hotlaps`
if ($mySQLiConn->query($createTableHotlaps)) {
$pageSuccess[] = "Successfully created table `hotlaps`.";
} else {
$pageErrors[] = "Error creating table `hotlaps`: (" . $mySQLiConn->error . ")";
}
// -- create table `racelaps`
if ($mySQLiConn->query($createTableRacelaps)) {
$pageSuccess[] = "Successfully created table `racelaps`.";
} else {
$pageErrors[] = "Error creating table `racelaps`: (" . $mySQLiConn->error . ")";
}
// -- create table `sessioninfos`
if ($mySQLiConn->query($createTableSessioninfos)) {
示例4: change_user
/**
* (non-PHPdoc)
* @see mysqli::change_user()
* @return bool
*/
public function change_user($user, $password, $database = NULL)
{
if (isset($database)) {
$this->setDb($database);
}
$this->setUsername($user);
$this->setPassword($password);
return parent::change_user($this->getUsername(), $this->password, $this->getDb());
}
示例5: mysqliConnect
function mysqliConnect($db = null)
{
$db = $db ? $db : $_SESSION['base_datos']->nombrebd;
$mysqli = new mysqli(BD_HOST, BD_SP_USUARIO, BD_SP_CLAVE, $db);
if (mysqli_connect_errno()) {
$error_db['TIPO ERROR'] = "LA BASE DE DATOS NO SE ENCUENTRA DISPONIBLE, ERROR DE CONEXIÓN";
$error_db['MYSQLI ERROR'] = mysqli_connect_error();
dpr($error_db);
exit;
}
$mysqli->change_user(BD_SP_USUARIO, BD_SP_CLAVE, $db);
return $mysqli;
}