ATTR_EMULATE_PREPARES on PDO

1. ATTR_EMULATE_PREPARES=true (default)
Meaning: local prepare
details: prepare is not sent, and complete SQL is sent when execute.
Advantages: When frequently prepare in the code, prepare is placed locally to reduce the pressure on the mysql server.
Disadvantages: SQL injection needs to take precautions by yourself
: The database data will be converted from int type to string. If php cooperates with object-c, there may be a problem. Be careful! ! !


2. ATTR_EMULATE_PREPARES=false
meaning: server (mysql) prepare
details: "query+placeholder" is sent to the server
during prepare Advantages: 1. Anti-sql injection; 2. Better performance when there is less prepare in the code
Disadvantages: 1. High Concurrency, frequent prepare, there will be performance problems; 2, slow log is a placeholder

Guess you like

Origin blog.csdn.net/weixin_38230961/article/details/108629901