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
In reply to Re^6: DBI do() SQL injection
by afoken
in thread DBI do() SQL injection
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |