1
Observing the reply of this question, I noticed that the user recommends to pass the parameters by the function bindValue
, indicating the type of parameter.
There is a various types of parameters that we can pass, but the ones that most catch my attention are the PDO::PARAM_STR
and the PDO::PARAM_INT
.
By default the function bindValue
always uses the string version.
When arriving in the database, Mysql makes a Typecast for the correct type of data according to the context. Considering this
- It is worth passing the parameter type when I go to pass an integer?
- I do not know other bank mechanisms, there is some bank that can present error by not being able to do the same Typecast that Mysql does?
- What about performance? Does it have an impact? In my understanding, there will be a Typecast on the PHP side or on the bank side, it remains to be seen which will be more advantageous.
Have almost certainty that is duplicated
– MarceloBoni
Could you indicate the duplicate question?
– jlHertel
A case where the int makes a difference.
– rray
Linked: What is the difference between bindParam and bindValue?
– MarceloBoni
@Bonifazio, the questions are really close, but my doubt is more focused on the problems that can be caused by not passing the type. On the other hand, the question that rray posed seems to me to answer this one. I don’t know if it’s worth someone to answer my question or mark it as duplicate.
– jlHertel