http://qs321.pair.com?node_id=11142185


in reply to Re^6: Best practices for closing database connections?
in thread Best practices for closing database connections?

For placeholders, here's my take.
  1. Efficiency? I doubt that you'd ever spot a difference.
  2. Security? Yes, but it's not as simple as trivial SQL injection. In another message you wrote that "Quotes are escaped". I guess you are aware that different database engines allow different escaping mechanisms? That's why DBI offers the quote method to do the right thing for your particular database engine. You might, at some point in the future, fall in love with a different SQL engine. If you use placeholders, the engine's driver will use its correct quoting. Manually quoting every string with $dbh->quote works, too, but is cumbersome to review and more work if you add columns. Once you got into the habit of using placeholders, you and everyone reading your code can see that quoting has been taken care of.
  3. Because Perl culture says so? Well, every other programming language I've been using has the same recommendation: Use placeholders.