Doc #76315 [NEW]: Clarify if colons are actually necessary to bind named placeholders
From: alvaro at demogracia dot com
Operating system:
PHP version: Irrelevant
Package: PDO Core
Bug Type: Documentation Problem
Bug description:Clarify if colons are actually necessary to bind named placeholders
Description:
------------
All around PDO documentation (e.g. [1]) it's suggested that named
placeholders use the ":foo" syntax both in SQL code and in parameter
binding code.
The former is obviously true, the latter is unclear. Omitting colons has
always seemed to work in several drivers but I don't know if it's a
behaviour to trust and it doesn't seem to be mentioned in
documentation.
Please also check "What are colons in parameter names used for?" [2] at
Stack Overflow.
[1] http://php.net/manual/en/pdostatement.bindvalue.php
[2]
https://stackoverflow.com/questions/17386469/pdo-prepared-statement-what-are-colons-in-parameter-names-used-for
Test script:
---------------
<?php
$dbh = new PDO('mysql:host=localhost', 'test', 'test',
array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,));
$sth = $dbh->prepare('SELECT :text AS greeting FROM DUAL');
$sth->bindValue('text', 'Hello, World!', PDO::PARAM_STR);
$sth->execute();
var_dump($sth->fetch(PDO::FETCH_ASSOC));
--
Edit bug report at https://bugs.php.net/bug.php?id=76315&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=76315&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=76315&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=76315&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=76315&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=76315&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=76315&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=76315&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=76315&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=76315&r=support
Expected behavior: https://bugs.php.net/fix.php?id=76315&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=76315&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=76315&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=76315&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76315&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=76315&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=76315&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=76315&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=76315&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=76315&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=76315&r=mysqlcfg
Thread (4 messages)
- alvaro at demogracia dot com