php.net |  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
Votes:2
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
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: codedokode at gmail dot com
New email:
PHP Version: OS:

 

 [2017-11-13 17:59 UTC] 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. 



Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-01-01 22:29 UTC] girgias@php.net
-Package: Documentation problem +Package: MySQL related
 [2023-01-10 17:11 UTC] dharman@php.net
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: Tue Mar 19 10:01:30 2024 UTC