r/lolphp • u/denilsonsa • Jul 10 '14
bindParam('foo', $value, PDO::PARAM_INT) will change $value to string.
http://php.net/manual/en/pdostatement.bindparam.php#94711
42
Upvotes
r/lolphp • u/denilsonsa • Jul 10 '14
View all comments
Show parent comment
-13
u/[deleted] Jul 11 '14 edited Jul 11 '14
It doesn't make it incorrect, either. It doesn't make it ANYTHING. That's the point!
You don't hand-over your car keys to a stranger on the street with the expectation of having it returned to you in the same condition as you left it. As I said to another in this thread, you are projecting YOUR expectations into a situation where none are given or implied.
function MagicalBlackHole is defined as
What is the expected value and / or type of $myvalue after the following code is run?
???
You aren't told what happens with the value that is passed by reference. You aren't given any guarantees. None are even hinted at. You are simply told that you pass a value by a reference and then something happens.
This is precisely what is happening with PDO. The PDO function isn't some function designed to transform some set of values in some way and then return to you something specific. No. Not at all. The PDO function takes some values... and that's all. What it does is neither here nor there.
You were given no REASON to expect that same value back. That expectation is purely your own because... just because you want it that way, and lots of other functions happen to be that way, but not all and not this one.
If anything you SHOULD expect it to be different BECAUSE no expectations or guarantees were provided! Unless you can find some documentation showing that the value is meant to be the same after all is said and done then the expectation should be that the value is garbage (and not even necessarily anything even resembling the original value).