Is there a way of using PHP PDO::quote method without creating a connection?
问题 I've been using PDO::quote to generate SQL statements. I use the generated SQL to create a memcached key. I'd like to avoid having to create a connection solely for the purpose of escaping SQL values. What is the purpose of needing to establish a connection to use PDO::quote method and can it be avoided? 回答1: Because PDO is an abstraction layer, and each database's quoting methods differ. PDO must know WHICH database you're going to be using to be able to use the proper quoting/escaping API