Doc #66696 [Opn->Csd]: Slight error in description

From: Date: Tue, 14 Jun 2016 15:49:25 +0000
Subject: Doc #66696 [Opn->Csd]: Slight error in description
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-13522@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=66696&edit=1 ID: 66696 Updated by: cmb@php.net Reported by: php_bugs at multiwebinc dot com Summary: Slight error in description -Status: Open +Status: Closed Type: Documentation Problem Package: Documentation problem Operating System: Debian PHP Version: 5.4.25 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: Yes, apparently this ticket has been overlooked. Previous Comments: ------------------------------------------------------------------------ [2015-07-23 23:04:57] php_bugs at multiwebinc dot com I guess whoever fixed it didn't notice this bug report. I don't remember the password, so whoever has access please close this. It is fixed. ------------------------------------------------------------------------ [2015-07-23 20:47:05] chealer at gmail dot com The manual does say: You cannot use a named parameter marker of the same name more than once in a prepared statement, ***unless emulation mode is on***. ------------------------------------------------------------------------ [2014-02-12 07:10:11] php_bugs at multiwebinc dot com 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 this bug report at https://bugs.php.net/bug.php?id=66696&edit=1

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