|  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: codedokode at gmail dot com
New email:
PHP Version: OS:


 [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: Sat Jul 20 16:01:29 2024 UTC