Doc #66696 [NEW]: Slight error in description

From: Date: Wed, 12 Feb 2014 07:10:12 +0000
Subject: Doc #66696 [NEW]: Slight error in description
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-10976@lists.php.net to get a copy of this message
From: php_bugs at multiwebinc dot com Operating system: Debian PHP version: 5.4.25 Package: Documentation problem Bug Type: Documentation Problem Bug description:Slight error in description Description: ------------ --- From manual page: http://www.php.net/pdo.prepare --- The manual says "You cannot use a named parameter marker of the same name twice in a prepared statement", however this is not completely true. If PDO::ATTR_EMULATE_PREPARES is set to true, you *can* re-use the same parameter marker more than once. I'm not sure if this is a bug with the docs or a bug with PDO. Test script: --------------- The following worked just fine for me by default (I'm assuming prepared statements were being emulated): <?php $stmt = $dbh->prepare(" SELECT tour_photo_id, name, desc FROM ( SELECT tour_photo_id, tours_i18n.name, desc FROM tour_photos LEFT JOIN tour_photos_i18n ON tour_photos.id = tour_photos_i18n.tour_photo_id LEFT JOIN tours ON tour_photos.tour_id = tours.id LEFT JOIN tours_i18n ON tours.id = tours_i18n.tour_id WHERE tour_photos.id IN (".implode(',', $banner_img_ids).") AND tours_i18n. lang_id = :lang_id AND tour_photos_i18n.lang_id = :lang_id UNION SELECT tour_photo_id, tours_i18n.name, desc FROM tour_photos LEFT JOIN tour_photos_i18n ON tour_photos.id = tour_photos_i18n.tour_photo_id LEFT JOIN tours ON tour_photos.tour_id = tours.id LEFT JOIN tours_i18n ON tours.id = tours_i18n.tour_id WHERE tour_photos.id IN (".implode(',', $banner_img_ids).") AND tours_i18n. lang_id = :en_lang_id AND tour_photos_i18n.lang_id = :en_lang_id ) a GROUP BY tour_photo_id ORDER BY FIELD(tour_photo_id, ".implode(',', $banner_img_ids).") "); $stmt->bindValue(':lang_id', $lang_id); $stmt->bindValue(':en_lang_id', $en_lang_id); $stmt->execute(); ?> Note, both :lang_id and :en_lang_id are used more than once. However when I set PDO::ATTR_EMULATE_PREPARES to false, I get 'SQLSTATE[HY093]: Invalid parameter number'. -- Edit bug report at https://bugs.php.net/bug.php?id=66696&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=66696&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=66696&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=66696&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=66696&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=66696&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=66696&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=66696&r=needscript Try newer version: https://bugs.php.net/fix.php?id=66696&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=66696&r=support Expected behavior: https://bugs.php.net/fix.php?id=66696&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=66696&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=66696&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=66696&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=66696&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=66696&r=dst IIS Stability: https://bugs.php.net/fix.php?id=66696&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=66696&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=66696&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=66696&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=66696&r=mysqlcfg

« previous php.doc.bugs (#10976) next »