Doc #65534 [Opn->Nab]: result of mysqli::__connect
Edit report at https://bugs.php.net/bug.php?id=65534&edit=1
ID: 65534
Updated by: krakjoe@php.net
Reported by: kit dot lester at mail dot com
Summary: result of mysqli::__connect
-Status: Open
+Status: Not a bug
Type: Documentation Problem
Package: Documentation problem
PHP Version: 5.5.3
Block user comment: N
Private report: N
New Comment:
This isn't a bug in PHP.
Construction always results in an object or exception, that's just how PHP works.
The documentation doesn't lead you to believe that you are supposed to check the return value
of this particular function, so I don't see a need to change anything.
Previous Comments:
------------------------------------------------------------------------
[2013-08-23 11:56:52] kit dot lester at mail dot com
Description:
------------
It would be nice if the description of the result in the manual page on mysqli::__construct() could
say something like that the result "is of type mysqli, even if the connection fails (i.e. never
null)"; and somewhere (maybe with the result) that errno should be checked to determine whether
the operation failed.
An early example with a note that one doesn't do things the C/C++ way would also be
enlightening.
This would assist those of us coming from systems in which failures of constructors commonly return
NULL and failures of functions commonly return FALSE - very common in libraries for C and languages
derived from C.
[I can't be alone in being a little slow to realize that you've done thing in a better
way, at the price that I've some extra work to do in converting code to PHP+mysqli :-) ]
Much the same applies to all other manual pages on any constructor or method with an errno (or in
this case connect_errno) that should routinely be checked - so (apologies!) this is a meta-comment
applying to many of the manual's pages. [My own old scars tell me that I'd requesting a
substantial documentation-editing effort.]
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=65534&edit=1
Thread (2 messages)