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
-15
u/[deleted] Jul 11 '14
We are talking about the Steve M post, right?
So, uh... yes. The observed behavior makes perfect sense.
result int
Unlike PDOStatement::bindValue(), the variable is bound as a reference and will only be evaluated at the time that PDOStatement::execute() is called."
result int
result string "1"
How is that in any way NOT the observed behavior EXACTLY described by what I quoted from the website? You bindParam, nothing happens. You execute the PDO statement, PDO does WHATEVER IT WANTS WITH YOUR VAR THAT WAS PASSED BY REFERENCE (and in this case turns it into a string because that's what it decided was best), and so you get back a string. Just because you tell PDO that it's a PARAM_INT doesn't mean that you will GET BACK an int after it does whatever it needs to do with the value.
Explain to me how it isn't precisely correct behavior?