You've got to remember that the ';' is not part of the SQL syntax. It's interpreted by the command line tool that you use to access MySQL (or Oracle, or Sybase...) as a statement separator.
Michael
| [reply] |
OK, well, if this is the case, and neither do() nor prepare() will work if given a string with a semicolon (as if someone had tried to insert a second statement in the form), then why all the hubbub about using placeholders and worrying about someone trying to execute extra commands? Or am I missing something? (I probably am.) Can somebody point me to an explanation somewhere? Thanks.
| [reply] |
OK, well, if this is the case, and neither do() nor prepare() will work if given a string with a semicolon (as if someone had tried to insert a second statement in the form), then why all the hubbub about using placeholders and worrying about someone trying to execute extra commands?
The behavior is database dependent. Though there appears to not be a problem with MySQL, the advice to not construct queries from un-detainted pieces is still sound. Scripts written with one database in mind tend to migrate to other platforms, or are used as templates for new scripts. It's better to "get things right" even if there's no direct risk on the current platform mix.
| [reply] |