Doc #70120 [Opn->Csd]: PDO::prepare - First argument does not have to be a valid SQL statement
| From: | cmb@php.net | Date: | Wed, 29 Jul 2015 00:18:53 +0000 |
| Subject: | Doc #70120 [Opn->Csd]: PDO::prepare - First argument does not have to be a valid SQL statement | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-12564@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=70120&edit=1
ID: 70120
Updated by: cmb@php.net
Reported by: chealer at gmail dot com
Summary: PDO::prepare - First argument does not have to be a
valid SQL statement
-Status: Open
+Status: Closed
Type: Documentation Problem
-Package: Documentation problem
+Package: PDO related
-Operating System:
+Operating System: *
PHP Version: Irrelevant
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation better.
Previous Comments:
------------------------------------------------------------------------
[2015-07-29 00:17:48] cmb@php.net
Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&revision=337261
Log: clarified $statement parameter description of PDO::prepare (fixes #70120)
------------------------------------------------------------------------
[2015-07-23 23:25:27] chealer at gmail dot com
"statement template" is precisely the term used on Wikipedia: https://en.wikipedia.org/wiki/Prepared_statement
------------------------------------------------------------------------
[2015-07-23 21:01:59] chealer at gmail dot com
Description:
------------
statement
This must be a valid SQL statement for the target database server.
---
From manual page: http://www.php.net/pdo.prepare
---
In fact, as the text above explains, if parameters are used, the first argument must contain a
string similar to a SQL statement, but which is not a valid SQL statement (for example, "SELECT
name, colour, calories FROM fruit WHERE calories < ? AND colour = ?"). There is a
terminological challenge here - perhaps "statement template" would appropriately describe
what the argument actually contains.
The text above is less misleading, but is also incorrect:
The SQL statement can contain zero or more named (:name) or question mark (?) parameter markers for
which real values will be substituted when the statement is executed. You cannot use both named and
question mark parameter markers within the same SQL statement; pick one or the other parameter
style.
By the way, this does not specify what named parameter markers are, and the manual apparently never
does that. Quite clearly, these start with a colon, but there is no specification of what
constitutes a name. Visibly, names cannot contain a dot, although the error message leaves me
wondering whether that is a bug ("PHP Fatal error: Uncaught exception 'PDOException'
with message 'SQLSTATE[42000]: Syntax error or access violation: 0 [Sybase][ODBC Driver][SQL
Anywhere]L'expression près de ':?.nomdossier' est incorrecte", while the
parameter marker I tried using is ":dossr.nomdossier").
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=70120&edit=1