Edit report at http://bugs.php.net/bug.php?id=51818&edit=1
ID: 51818 Comment by: robert dot schlak at alcatel-lucent dot com Reported by: zeusgerde at arcor dot de Summary: var_dump(): Couldn't fetch mysqli Status: Wont fix Type: Bug Package: MySQLi related Operating System: Linux PHP Version: 5.3.2 Assigned To: mysql New Comment: The intent of the connect_errno method is to determine if an connection error occurred...one would think. The programmer is expecting the chance a connection error occurred. Don't error-out if he asks. $host = 'bad_host';// FORCE AN ERROR -- debug $mysqli = @new mysqli($host, NTSM_USER, PWD_NTSM, NTSM_INSTANCE); if ($mysqli->connect_errno) { do something } One would expect the code above to not annoy the user with an echoed warning. I have to use @$mysqli->connect_errno, but I have no return from the method call. Instead I receive 'Couldn't fetch mysqli in', why is a fetch even attempted with this method? Look at the local object and see if it contains an error status and return it. Previous Comments: ------------------------------------------------------------------------ [2010-05-25 18:55:35] and...@php.net I think this is a won't fix. The properties of the mysqli or mysql_result object are invalid if the connection establishment or the connection is closed. In case of mysql_result is something wrong happens. The extension needs different design, new mysqli(...) tries to connect, if something wrong happens it should throw an exception, it doesn't now. The design can't be changed that easily in a minor release. ------------------------------------------------------------------------ [2010-05-14 03:47:55] zeusgerde at arcor dot de Description: ------------ E_WARNING when accessing properties or methods of MySQLi object if connection fails I know other people already reported this kind of issue: http://bugs.php.net/bug.php?id=33635 http://bugs.php.net/bug.php?id=34828 http://bugs.php.net/bug.php?id=36949 http://bugs.php.net/bug.php?id=45935 http://bugs.php.net/bug.php?id=45940 http://bugs.php.net/bug.php?id=50772 though I think telling the user "couldn't fetch *mysqli*" is just wrong because PHP is able to use the MySQLi object and even some of its properties or methods (e.g. MySQLi::$client_version or MySQLi::$connect_errno) i am not sure if this is a real bug report or may be a feature request. but I think it would help other people if the warning says something like "mysqli is not connected" or may be E_WARNING should not be raised at all. -- PHP 5.3.2 (cli) (built: May 14 2010 03:25:13) MySQLi Client API library version 5.1.45 Test script: --------------- <?php error_reporting(E_ALL); // not bug related ini_set('display_errors', 1); // not bug related $foo = new MySQLi('localhost', 'root', 'wrongpassword'); // alternative to the line above, same result: $foo = new MySQLi(); var_dump($foo); ?> Expected result: ---------------- object(mysqli)#1 (17) { /* ... */ } Actual result: -------------- Lots of "Warning: var_dump(): Couldn't fetch mysqli in [...]" (for nearly every single key in mysqli) object(mysqli)#1 (17) { /* content as expected */ } ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=51818&edit=1