php.net |  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: 2016-06-14 15:58 UTC
From: php_bugs at multiwebinc dot com Assigned:
Status: Open Package: PDO related
PHP Version: 5.6Git-2014-02-12 (Git) OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2014-02-12 23:21 UTC] php_bugs at multiwebinc dot com
Description:
------------
---
From manual page: http://www.php.net/pdo.query
---

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" (http://dev.mysql.com/doc/refman/5.6/en/sql-syntax-prepared-statements.html#idm46981480871472) or else you get something like:

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

Test script:
---------------
<?php

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


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-06-14 15:58 UTC] cmb@php.net
-Package: Documentation problem +Package: PDO related
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 21:01:27 2019 UTC