#45646 [Opn]: Failed Connect Does Not Return FALSE
| From: | djneoform at gmail dot com | Date: | Tue, 29 Jul 2008 21:04:26 +0000 |
| Subject: | #45646 [Opn]: Failed Connect Does Not Return FALSE | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-1023@lists.php.net to get a copy of this message | ||
ID: 45646
User updated by: djneoform at gmail dot com
Reported By: djneoform at gmail dot com
Status: Open
Bug Type: Documentation problem
Operating System: Win2k3 Standard
PHP Version: 5.2.6
New Comment:
What then is the proper way to verify that a connection has been
established while using the OO version?
It seems innapropriate to be using a class object, only to use
mysqli_connect_errno() in order to verify that the connection was
established.
Previous Comments:
------------------------------------------------------------------------
[2008-07-29 21:01:44] jani@php.net
The manual page isn't quite clear that this concerns only the
procedural style connect, not the OO way.
------------------------------------------------------------------------
[2008-07-28 14:49:21] djneoform at gmail dot com
Description:
------------
When a mysqli connection fails, the returned value is an empty mysqli
object and not a bool(FALSE), this means any tests on the connection
will not work, eg: if ($conn) { ... }
When the documentation: http://ca.php.net/manual/en/mysqli.connect.php
States:
"Return Values
Returns a object which represents the connection to a MySQL Server or
FALSE if the connection failed."
Reproduce code:
---------------
<?php
$connection = new mysqli('localhost', 'badinfo', 'badinfo',
'badinfo');
var_dump($connection);
?>
Expected result:
----------------
bool(FALSE)
Actual result:
--------------
object(mysqli)#1 (0) { }
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=45646&edit=1