文字

MysqlndUhConnection::changeUser

(PECL mysqlnd-uh >= 1.0.0-alpha)

MysqlndUhConnection::changeUserChanges the user of the specified mysqlnd database connection

说明

public bool MysqlndUhConnection::changeUser ( mysqlnd_connection $connection , string $user , string $password , string $database , bool $silent , int $passwd_len )

Changes the user of the specified mysqlnd database connection

参数

connection

Mysqlnd connection handle. Do not modify!

user

The MySQL user name.

password

The MySQL password.

database

The MySQL database to change to.

silent

Controls if mysqlnd is allowed to emit errors or not.

passwd_len

Length of the MySQL password.

返回值

Returns TRUE on success. Otherwise, returns FALSE

范例

Example #1 MysqlndUhConnection::changeUser() example

<?php
class  proxy  extends  MysqlndUhConnection  {
 

 
public function  changeUser ( $res $user $passwd $db $silent $passwd_len ) {
   
printf ( "%s(%s)\n" __METHOD__ var_export ( func_get_args (),  true ));
   
$ret  parent :: changeUser ( $res $user $passwd $db $silent $passwd_len );
   
printf ( "%s returns %s\n" __METHOD__ var_export ( $ret true ));
   return 
$ret ;
 }
}

mysqlnd_uh_set_connection_proxy (new  proxy ());


$mysqli  = new  mysqli ( "localhost" "root" "" "test" );


var_dump ( $mysqli -> change_user ( "root" "bar" "test" ));
?>

以上例程会输出:

proxy::changeUser(array (
  0 => NULL,
  1 => 'root',
  2 => 'bar',
  3 => 'test',
  4 => false,
  5 => 3,
))
proxy::changeUser returns false
bool(false)

参见

  • mysqlnd_uh_set_connection_proxy() - Installs a proxy for mysqlnd connections
  • mysqli_change_user() - Changes the user of the specified database connection
上一篇: 下一篇: