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


in reply to Counting rows Sqlite

You have a second problem: You don't use placeholders. That usually means that you are vulnerable to SQL injection, and you prevent any caching of prepared statements.

Always use placeholders, even if the underlying database does not support placeholders. Placeholders are part of the DBI specification, so you can use them with ANY database and pseudo-database supported by DBI. Each database driver (DBD::Whatever) must support placeholders, and together with the DBI, it will take care of proper quoting if needed. Since most database support parameters, there is no need for quoting or modification of the SQL statement, the values are simply passed through a different part of the communication channel to the database, and so the database can optimize and cache much better than with inline values.

I would prefer that DBI issued a warning or even refuse to work with inline values, but that would add a lot of overhead, as DBI would need to actually parse the SQL statement.

Alexander

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