php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #44169 Limitations of emulated PS / PDO::prepare() docs are wrong
Submitted: 2008-02-19 14:20 UTC Modified: 2008-11-07 11:47 UTC
From: uwendel at mysql dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: 5.3CVS-2008-02-19 (CVS) OS: Linux
Private report: No CVE-ID: None
 [2008-02-19 14:20 UTC] uwendel at mysql dot com
Description:
------------
PDO either uses native PS or its own PS emulation. The emulation has its limits. I tend to say that the manual should be more open in respect to this and discuss the limitations. I would like to see some clearification of what is supported and what is not supported by the emulated PS implemented in PDO. Any chance?

To give an example what I mean, let's "abuse" PDO::prepare() and show that the manual comes a bit short. The manual says about PDO::prepare():

"Return Values

If the database server successfully prepares the statement, PDO->prepare() returns a PDOStatement object. If the database server cannot successfully prepare the statement, PDO->prepare() returns FALSE.", http://de.php.net/manual/en/function.PDO-prepare.php

Its wrong that the database server is involed during prepare. 

It depends on the driver and the question wheter you use emulated or native PS. With emulated PS, its likely that prepare() accepts an invalid statement. The database server will not be used to check the syntax of the statement. With native PS, its likely that prepare() will fail to prepare an invalid statement, because the database server  gets contacted by prepare() and has a chance to check the statement.

As said, I don't know what to call this bug report: feature request, documentation request, bug... 

Reproduce code:
---------------
nixnutz@ulflinux:~/php53> sapi/cli/php -r '$pdo=new PDO("mysql:dbname=phptest;unix_socket=/tmp/mysql.sock", "root", "root"); var_dump($pdo->prepare("SELECT ice FROM artica AND antarctica"));'
object(PDOStatement)#2 (1) {
  ["queryString"]=>
  string(37) "SELECT ice FROM artica AND antarctica"
}
nixnutz@ulflinux:~/php53> sapi/cli/php -r '$pdo=new PDO("pgsql:host=localhost port=5432 dbname=phptest user=postgres password="); var_dump($pdo->prepare("SELECT ice FROM artica AND antarctica"));'
object(PDOStatement)#2 (1) {
  ["queryString"]=>
  string(37) "SELECT ice FROM artica AND antarctica"
}
nixnutz@ulflinux:~/php53> sapi/cli/php -r '$pdo=new PDO("sqlite:/tmp/foo.db"); var_dump($pdo->prepare("SELECT ice FROM artica AND antarctica"));'
bool(false)

Expected result:
----------------
At least a hint in the documentation. Even better would be a full documentation of how capable emulated prepared statements are in PDO.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-11-07 11:47 UTC] vrana@php.net
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.

"Emulated prepared statements does not communicate with the database server so PDO::prepare() does not check the statement."
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 20:01:29 2024 UTC