What is the double quotation marks in php pdo? why does this statement look good by finding a lightweight database class medoo? I found a strange problem during use?
When mysql is used, the SQL table name and field name assembled by mysql are enclosed in double quotation marks, so that the generated statement cannot be executed directly.
mysql> SELECT * FROM "dd_xq_user_info" WHERE "uid" = '1' AND "status" = '1' ORDER BY "id" LIMIT 1;ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"dd_xq_user_info" WHERE "uid" = '1' AND "status" = '1' ORDER BY "id" LIMIT 1' at line 1
But the execution of this statement with pdo is successful, and there is no error. why? What does pdo do?
Reply to discussion (solution)
This is impossible!
Paste your real code
Just now I read through the code https://github.com/catfan/Medoo/blob/master/medoo.php of medoo
It is found that a statement is executed when the database is connected.
SET SQL _MODE = ANSI_QUOTES
The function of this mode is to change the double quotation marks to reverse quotation marks.
ANSI_QUOTES regards 'as an identifier quotation mark ('''). do not treat it as a string quotation mark character. In ANSI mode, you can still use ''' to reference the identifier. When ANSI_QUOTES is enabled, you cannot use double quotation marks to reference strings because it is interpreted as an identifier.
This explains why the preceding statement can be executed.
I cannot think of any other problems for the moment.
The default value of SQL _MODE is STRICT_TRANS_TABLES, NO_AUTO_CREATE_USER, NO_ENGINE_SUBSTITUTION.
After being changed to ANSI_QUOTES, no other operations will naturally not be affected.
This is a MySQL function, not PDO's
This is a MySQL function, not PDO's
Yes. I thought pdo had this function.
By the way, I wish you good luck at the Dragon Boat Festival. thank you for answering questions during the festival.