Re: [PECL-DEV] mysqlnd_qc (mysqlnd query cache) 1.0.1 with prepared statement support
[email protected] (Ulf Wendel)
| Newsgroups | php.pecl.dev |
|---|---|
| Message-ID | <[email protected]> |
Benjamin Eberlei schrieb:
> How does PDO emulation of prepared statements affect the QC? Mysqlnd
> always gets the bound SQL statement? I.e. query cache always works?
PDO emulation uses plain vanilla queries to simulate a bind like API.
The query cache can handle plain vanilla queries.
If you code looks like this, it can be cached already in the 1.0.0:
nixnutz@linux-fuxh:~/php/php-src/trunk_qc> sapi/cli/php -d
mysqlnd.debug="d:t:O,/tmp/pdo.trace" -r 'var_dump(phpversion()); $pdo =
new PDO("mysql:host=localhost;dbname=test", "root", "root"); $stmt =
$pdo->prepare("SELECT 1 FROM DUAL LIMIT ?"); $stmt->execute(array(2));
var_dump($stmt->errorInfo());'
Of course the example lacks the SQL hints, uses a SQL statement with at
least one column with an empty table name and so one but... given proper
query and setup this can be cached in the 1.0.0 because PDO_MYSQL will
not use a native prepared statement.
Therefore, the lack of support for native prepared statement in 1.0.0
may be not that much of any issue for many.
That's why I wrote at
http://docs.php.net/manual/en/mysqlnd-qc.basic_usage.php that PDO's
prepared statements can be cached if PDO_ATTR_EMULATES_PREPARES = 1
(which is the default).
Ulf