in reply to Re^5: DBI do() SQL injection
in thread DBI do() SQL injection

If you have no control over the contents of $id, you shouldn't use it directly.

Even if you have control, you should use placeholders. Keeping the query string constant and only varying the parameters allows everything below DBI (i.e. the DBD and especially the database engine) to cache the already parsed query string, including all optimizations. Changing the query string for every new value of $id prevents that.

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)