#45646 [Opn->Csd]: Failed Connect Does Not Return FALSE
| From: | kalle@php.net | Date: | Wed, 20 Aug 2008 02:19:47 +0000 |
| Subject: | #45646 [Opn->Csd]: Failed Connect Does Not Return FALSE | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-1111@lists.php.net to get a copy of this message | ||
ID: 45646
Updated by: kalle@php.net
Reported By: djneoform at gmail dot com
-Status: Open
+Status: Closed
Bug Type: Documentation problem
Operating System: Win2k3 Standard
PHP Version: 5.2.6
-Assigned To:
+Assigned To: kalle
New Comment:
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation
better.
I changed the return values, and fixed the connect example to use
proper OO syntax and added a notice explaining how to find out if a
connection failed.
Previous Comments:
------------------------------------------------------------------------
[2008-07-29 21:04:26] djneoform at gmail dot com
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.
------------------------------------------------------------------------
[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