#38998 [Asn]: wrong default values in constructor

From: Date: Sat, 12 Jan 2008 18:15:25 +0000
Subject: #38998 [Asn]: wrong default values in constructor
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-440@lists.php.net to get a copy of this message
ID: 38998 Updated by: hholzgra@php.net Reported By: camka at email dot ee Status: Assigned -Bug Type: MySQLi related +Bug Type: Documentation problem Operating System: win 2000 PHP Version: 5.1.6 Assigned To: georg New Comment: Calling the constructor without any argument is like calling mysqli_init() to create a mysqli object, it does not try to connect at all in this case but waits for an explicit call to mysqli::connect() or mysqli::real_connect() which allows to set mysqli::options() before connecting Reclassified as documentation bug as the documentation on the mysqli constructor is not clear about this. Previous Comments: ------------------------------------------------------------------------ [2006-10-02 09:09:16] tony2001@php.net Assigned to the maintainer. ------------------------------------------------------------------------ [2006-10-02 09:04:02] camka at email dot ee This does not describe, why the first case does not give an error at all, even if the host is not reachable or does not exist: $m = mysqli(); // with no parameters ------------------------------------------------------------------------ [2006-10-02 08:54:51] tony2001@php.net NULL values passed as parameter to mysqli::__construct() have a special meaning, which are described in the docs. ------------------------------------------------------------------------ [2006-09-29 22:42:06] camka at email dot ee Description: ------------ If passing NULL parameters in mysqli::__construct, as they are by default, the values are not actually taken from php.ini (or apache conf) file. Tested with both 5.1.6 and 5.2 latest snapshot. Reproduce code: --------------- virtual host conf: php_admin_value "mysqli.default_host" zorro php_admin_value "mysqli.default_user" rootf php_admin_value "mysqli.default_pw" ff <? $m = new mysqli(); echo mysqli_connect_error(), "\n"; $m = new mysqli(null); echo mysqli_connect_error(), "\n"; $m = new mysqli(null, null); echo mysqli_connect_error(), "\n"; $m = new mysqli(null, null, null); echo mysqli_connect_error(), "\n"; ?> Expected result: ---------------- Access denied for user 'rootf'@'zorro' (using password: YES) Access denied for user 'rootf'@'zorro' (using password: YES) Access denied for user 'rootf'@'zorro' (using password: YES) Access denied for user 'rootf'@'zorro' (using password: YES) Actual result: -------------- [empty] Access denied for user 'rootf'@'localhost' (using password: YES) Access denied for user 'ODBC'@'localhost' (using password: YES) Access denied for user 'ODBC'@'localhost' (using password: NO) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=38998&edit=1

« previous php.doc.bugs (#440) next »