|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #65534 result of mysqli::__connect
Submitted: 2013-08-23 11:56 UTC Modified: 2013-10-02 19:53 UTC
Avg. Score:2.8 ± 0.4
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: kit dot lester at mail dot com Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: 5.5.3 OS:
Private report: No CVE-ID: None
 [2013-08-23 11:56 UTC] kit dot lester at mail dot com
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.]


new-mysqli-isnt-C-style-hurrah (last revision 2013-08-23 12:08 UTC by kit dot lester at mail dot com)

Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-10-02 19:53 UTC]
-Status: Open +Status: Not a bug
 [2013-10-02 19:53 UTC]
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.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Fri Sep 24 16:03:41 2021 UTC