Using PHP's PDO class, does preparing queries cause a (slight even) performance hit that isn't made up if you only execute the query once per connection? I'm making a small data access layer and I'm wondering if it's okay to blindly prepare all queries, or if I should only prepare queries that will be reused.
Prepared statements arent only for reused queries. They should be used for all queries that have untrusted data, making sure to bind the untrusted data. This eliminates SQL injection opportunities.
http://www.php.net/manual/en/pdo.prepared-statements.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With