|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2012-10-16 14:42 UTC] laruence@php.net
-Status: Open
+Status: Wont fix
[2012-10-16 14:42 UTC] laruence@php.net
[2012-10-16 15:08 UTC] laruence@php.net
[2012-10-16 15:29 UTC] jim dot gibbs at onelifemedia dot com
[2012-11-01 05:39 UTC] rawr at rawr dot com
[2012-11-01 16:17 UTC] giblets at mailinator dot com
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 13:00:01 2025 UTC |
Description: ------------ Created a prepared statement, with named placeholders. The prepared statement contained 2 queries, and 3 placeholders. 2 of the placeholders were the same, so they *should* become the same value. The resulting query ended up being all three place holders being the same value. The results below were generated from the mysql log files. Workaround: Instead of using the bindParam function, I was able to send the same array to the execute function, and it worked. Test script: --------------- $query = <<<QUERY DELETE FROM `authentication_hashes` WHERE session_key = :session_key; INSERT INTO `authentication_hashes` (`session_key`, `generated_hash`) VALUES (:session_key, :generated_hash); QUERY; $dbh = new PDO('mysql:host=localhost;port=8888;dbname=foo, $user, $pass, array (PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION)); $statement = $dbh->prepare($query); $bind_params = array(':session_key' => $session_key, ':generated_hash' => $generated_hash) foreach( $bind_params as $key => $value ){ $statement->bindParam($key, $value); } $statement->execute(); Expected result: ---------------- DELETE FROM `authentication_hashes` WHERE session_key = '8675309'; INSERT INTO `authentication_hashes` (`session_key`, `generated_hash`) VALUES ('8675309', 'cb5606644c1d30a9d8f84cee4234a44455c82448a33f8031434ec42a6d173383') Actual result: -------------- DELETE FROM `authentication_hashes` WHERE session_key = '3966b45ae07b86de9c74163b093994fbf2a5813a06cbc9902f15e1b38a212940'; INSERT INTO `authentication_hashes` (`session_key`, `generated_hash`) VALUES ('3966b45ae07b86de9c74163b093994fbf2a5813a06cbc9902f15e1b38a212940', '3966b45ae07b86de9c74163b093994fbf2a5813a06cbc9902f15e1b38a212940')