Find a lightweight database class Medoo, feel good, but when used to find a very strange problem
When using MySQL, he assembled SQL table names, field names in double quotation marks, so that the resulting 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 a error in your SQL syntax; Check the manual-corresponds to your MySQL server version for the right syntax-use "" Dd_xq_user_info "WHERE" UID "= ' 1 ' and" status "= ' 1 ' ORDER by" id "LIMIT 1 ' on line 1
However, the execution of this statement with PDO is successful, and there is no error, may I ask what this is all about? What does PDO do?
Reply to discussion (solution)
It's impossible!
Stick out your real code.
Just read through the next Medoo code https://github.com/catfan/Medoo/blob/master/medoo.php
Found executing a statement when connecting to the database
SET sql_mode=ansi_quotes
found that the function of this pattern is to change the double quotation mark to the inverted quotation mark
Ansi_quotes ' "' is treated as the identifier quotation mark (' ' ' quotation mark character), not as the quotation mark character of the string. In ANSI mode, you can still use "' to refer to identifiers. When Ansi_quotes is enabled, you cannot use double quotation marks to reference a string because it is interpreted as a qualifier.
This explains why the above statement can be executed
Can't think of any other problems for the time being.
The default value for Sql_mode is Strict_trans_tables,no_auto_create_user,no_engine_substitution
After the change to ansi_quotes, if there is no other operation, nature will not have an impact
This is the function of MySQL, not the PDO
This is the function of MySQL, not the PDO
Yes, I thought PDO had this function.
By the way I wish the Dragon Boat Festival health, thanks for the holiday also help answer