Doc #70120 [Opn]: PDO::prepare - First argument does not have to be a valid SQL statement
| From: | chealer at gmail dot com | Date: | Thu, 23 Jul 2015 23:25:28 +0000 |
| Subject: | Doc #70120 [Opn]: 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-12549@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
User updated by: chealer at gmail dot com
Reported by: chealer at gmail dot com
Summary: PDO::prepare - First argument does not have to be a
valid SQL statement
Status: Open
Type: Documentation Problem
Package: Documentation problem
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
"statement template" is precisely the term used on Wikipedia: https://en.wikipedia.org/wiki/Prepared_statement
Previous Comments:
------------------------------------------------------------------------
[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