Looking at the answer of this question, I noticed that the user recommends passing the parameters by the bindValue
function, indicating the parameter type.
There are various types of parameters we can pass, but the ones that catch my eye are the PDO::PARAM_STR
and PDO::PARAM_INT
.
By default the function bindValue
always uses the string version.
Upon arriving in the database, Mysql does a typecast for the correct type of data according to the context. Considering this
- Is it worth passing the parameter type when I pass an integer?
- I do not know about other bank mechanisms, is there any bank that might fail because it can not do the same typecast as Mysql does?
- What about the performance? Do you have any impact? In my understanding, there will be a typecast on the side of PHP or on the side of the bank, it remains to know which one will be most advantageous.