|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #66704 Small update needs to be made to the manual page
Submitted: 2014-02-12 23:21 UTC Modified: 2021-08-09 11:16 UTC
From: php_bugs at multiwebinc dot com Assigned: cmb (profile)
Status: Closed Package: PDO related
PHP Version: 5.6Git-2014-02-12 (Git) OS:
Private report: No CVE-ID: None
 [2014-02-12 23:21 UTC] php_bugs at multiwebinc dot com
From manual page:

From the PDO::query() and PDO::exec() manual pages it looks like they do exactly the same thing with the only difference being the return value, however reviewing the PHP source code, it appears that there is a subtle difference that I feel should be noted.

Since PDO::query() internally does a prepare() followed by an execute(), this means that the queries allowed must only contain syntax that is listed in the list of "SQL Syntax Allowed in Prepared Statements" ( or else you get something like:

"SQLSTATE[HY000]: General error: 2030 This command is not supported in the prepared statement protocol yet"

Test script:

// Note "USE" is not permitted in prepared statements (see the URL above)
$dbh->query("USE db_name"); // Fails
$dbh->exec("USE db_name"); // Works


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-06-14 15:58 UTC]
-Package: Documentation problem +Package: PDO related
 [2021-08-09 11:16 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2021-08-09 11:16 UTC]
This has recently been fixed; the docs[1] now state:

| Prepares and executes an SQL statement without placeholders

[1] <>
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Sep 21 06:03:36 2021 UTC