Beruflich Dokumente
Kultur Dokumente
mysqli_change_user
(PHP 5, PHP 7)
mysqli::change_user -- mysqli_change_user — Changes the user of the specified database
connection
Description ¶
Object oriented style
mysqli::change_user ( string $user , string $password , string $database ) : bool
Procedural style
mysqli_change_user ( mysqli $link , string $user , string $password , string
$database ) : bool
Changes the user of the specified database connection and sets the current database.
In order to successfully change users a valid username and password parameters must be
provided and that user must have sufficient permissions to access the desired database. If for any
reason authorization fails, the current user authentication will remain.
Parameters ¶
link
Return Values ¶
Returns TRUE on success or FALSE on failure.
Notes ¶
Note:
Using this command will always cause the current database connection to behave as if
was a completely new database connection, regardless of if the operation was completed
successfully. This reset includes performing a rollback on any active transactions,
closing all temporary tables, and unlocking all locked tables.
Examples ¶
Example #1 mysqli::change_user() example
Object oriented style
<?php
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
/* Set Variable a */
$mysqli->query("SET @a:=1");
Procedural style
<?php
/* connect database test */
$link = mysqli_connect("localhost", "my_user", "my_password", "tes
t");
/* check connection */
if (!$link) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
/* Set Variable a */
mysqli_query($link, "SET @a:=1");
/* close connection */
mysqli_close($link);
?>