Bug #48856 [Com]: PDO_Statement->bindParam binds multiple parameters of the same name

From: Date: Sat, 26 Sep 2015 01:33:34 +0000
Subject: Bug #48856 [Com]: PDO_Statement->bindParam binds multiple parameters of the same name
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-196253@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=48856&edit=1

 ID:                 48856
 Comment by:         a791446794 at 163 dot com
 Reported by:        dhammari at q90 dot com
 Summary:            PDO_Statement->bindParam binds multiple parameters
                     of the same name
 Status:             Assigned
 Type:               Bug
 Package:            PDO Core
 Operating System:   Linux 2.6.27-gentoo-r8
 PHP Version:        5.2.10
 Assigned To:        dbs
 Block user comment: N
 Private report:     N

 New Comment:

I want this feature too!
When sql has subquey with the same condition,it is fairly that use the same :token will be
maintainable and efficient.


Previous Comments:
------------------------------------------------------------------------
[2009-11-16 13:42:59] dbs@php.net

I've referred this bug to the PDO discussion list, as there are ongoing discussions about the
future design of PDO and this bug seems to be pertinent to that discussion.

------------------------------------------------------------------------
[2009-09-24 02:59:16] dbs@php.net

Yes, it was a limitation back then - and while it might work for some PDO drivers, I believe the
problem was that it was not guaranteed to work with all PDO drivers - and therefore discouraged. It
would be best for us to talk to a current PDO developer to get the real deal on the current
situation.

------------------------------------------------------------------------
[2009-09-23 18:07:30] dhammari at q90 dot com

Hi Bjori,

It seems to me that the ability to use the same token for multiple binds has arisen fairly recently.
I recall earlier releases of php 5 berating me for attempting to reuse a token in this manner as
recently as several months ago.

I have looked up documentation on this behavior before, and the articles I have found seem adamant
that multiple binding from a single token should be disallowed. For example, please take a look at
these previous bug reports from 2005 and 2007:

http://bugs.php.net/bug.php?id=33886
http://bugs.php.net/bug.php?id=40417

The discussions in these articles seem to reach a consensus that every time a variable in a prepared
PDO statement is bound, it should be bound to a unique token.

While I think it is useful to bind multiple parameters to a single token, I don't want to start
writing code that relies on this feature until I am assured that this is the intended behavior.
Otherwise, my code would not be future proof and could be invalidated by an upcoming release. I
would appreciate it if you could clarify the intended behavior and update php's documentation
accordingly.

Sincerely,
Dan Hammari

------------------------------------------------------------------------
[2009-09-23 17:29:56] bjori@php.net

No idea. Its been like this for almost 4years..
Dan? Was this originally a limitation in PDO?

------------------------------------------------------------------------
[2009-09-23 16:17:57] sjoerd@php.net

Bjori, do you know why this was in the documentation?

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=48856


--
Edit this bug report at https://bugs.php.net/bug.php?id=48856&edit=1


Thread (9 messages)

« previous php.bugs (#196253) next »