[php-src] Issue #10382: mysqli_change_user does not allow to use NULL for $database param

From: Date: Thu, 19 Jan 2023 22:01:56 +0000
Subject: [php-src] Issue #10382: mysqli_change_user does not allow to use NULL for $database param
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-243505@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/10382 Author: kamil-tekiela ### Description According to the documentation, the third parameter in [mysqli_change_user](https://www.php.net/manual/en/mysqli.change-user.php) is nullable (not optional though) and passing NULL should connect to the same database. > If desired, the null value may be passed resulting in only changing the user and not selecting > a database. To select a database in this case use the > [mysqli_select_db()](https://www.php.net/manual/en/mysqli.select-db.php) function. But to my knowledge this was never possible and is still not supported by mysqli. This code will reset database to NULL ```php $mysqli = new mysqli("localhost", "my_user", "my_password", "test"); $mysqli->change_user("my_user", "my_password", null); var_dump($mysqli->query("SELECT DATABASE()")->fetch_row()[0]); ``` Resulted in this output: ``` NULL ``` But I expected this output instead: ``` string(4) "test" ``` ### PHP Version All versions ### Operating System _No response_

« previous php.bugs (#243505) next »