in reply to Re: Is bind useful for one-time queries and commands?
in thread Is bind useful for one-time queries and commands?
if you bind a string parameter bind escapes the characters that could be interpreted as statement by the DBMS and doing so it prevents the all-present risk of code injection if data comes from user input.That's what placeholders are for, too. I mean, duh!
You can combine use of placeholders with bind_param (between prepare and the first execute) to make sure only certain datatypes are acceptable.
In fact, I had to do this when I used DBD::ODBC with MS-Access, in case a parameter was undefined in the first call to execute, because otherwise, DBI performed an implicit bind_param with possibly the wrong type, and I occasionally got an error in one of the next loops, with a defined value for that parameter.
|
|---|