Does php pdo process double quotation marks? why can this statement be executed through

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.