|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #75518 Better code examples for article "Choosing an API [to access MySQL server]"
Submitted: 2017-11-13 17:59 UTC Modified: 2023-01-10 17:11 UTC
Avg. Score:2.0 ± 1.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: codedokode at gmail dot com Assigned:
Status: Open Package: MySQL related
PHP Version: Irrelevant OS: Irrelevant
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
46 - 33 = ?
Subscribe to this entry?

 [2017-11-13 17:59 UTC] codedokode at gmail dot com
The article "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 if this change is approved. 

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


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-01-01 22:29 UTC]
-Package: Documentation problem +Package: MySQL related
 [2023-01-10 17:11 UTC]
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.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Jul 18 17:01:29 2024 UTC