If i have a parameterized SQL statement like this:
SELECT * FROM table WHERE my_field = :field_value
Does anyone know if PDO will recognize this(see below) as the same SQL statement and use the cache instead of assuming it’s a completely different SQL statement:
SELECT * FROM table WHERE my_field = :new_field_value
So, I guess the question is: if the name of a parameter changes in a parameterized select statement but nothing else changes, will I still get the performance benefit of caching? Or do I have to make sure that the parameter name stays the same?
If you’re using PDO_MySQL, it rewrites prepared statements into raw SQL on its own before the server even sees them, unless you set
PDO::ATTR_EMULATE_PREPARESto false.