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

From: Date: Tue, 10 Jan 2023 17:11:13 +0000
Subject: Doc #75518 [Opn]: Better code examples for article "Choosing an API [to access MySQL server]"
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-19551@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75518&edit=1

 ID:                 75518
 Updated by:         dharman@php.net
 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


Thread (2 messages)

« previous php.doc.bugs (#19551) next »