Doc #75518 [Opn]: Better code examples for article "Choosing an API [to access MySQL server]"

[email protected] Tue, 10 Jan 2023 17:11:13 +0000
Newsgroups php.doc.bugs
Message-ID <[email protected]>
Edit report at https://bugs.php.net/bug.php?id=75518&edit=1

 ID:                 75518
 Updated by:         [email protected]
 Reported by:        codedokode at gmail dot com
 Summary:            Better code examples for article "Choosing an API
                     [to access MySQL server]"
 Status:             Open
 Type:               Documentation Problem
 Package:            MySQL related
 Operating System:   Irrelevant
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

Both extensions support exception mode which is the default mode now. 

In regards to parameters, this is true. A second example showing prepared statements is needed.


Previous Comments:
------------------------------------------------------------------------
[2017-11-13 17:59:30] codedokode at gmail dot com

Description:
------------
The article http://php.net/manual/en/mysqlinfo.api.choosing.php "Choosing an API [to access MySQL server]" has incorrect code examples that can mislead users. 

First, there is no error handling. In real world examples, of course, error handling is required. For PDO, this can be solved with one line, enabling exceptions (although my personal opinion is that this mode should be teh default). But for mysqli, the error handling should be made explicitly by adding if operator after every method call. 

Also, the code examples should have at least one argument inserted via placeholders. In real world code almost all queries will have parameters and it is important to show that parameters are easier to insert using PDO.

I can correct the code examples using edit.php.net if this change is approved. 

I would also like to add a line "supports exceptions" to API comparison table. 




------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=75518&edit=1