PDO operation. if the ATTR_EMULATE_PREPARES attribute is set to false, it is found that the prepare is still simulated locally.

Source: Internet
Author: User
In the PDO operation, if the ATTR_EMULATE_PREPARES attribute is set to false, it is found that the prepare {code...} is still simulated locally ...} mysql log: {code ...} it is not found as described below: "Setting this attribute to false will not simulate prepare locally." php 5.2.17 supplement... PDO operation. if the ATTR_EMULATE_PREPARES attribute is set to false, it is found that the prepare is still simulated locally.


  SetAttribute (PDO: ATTR_ERRMODE, PDO: ERRMODE_EXCEPTION); // Set to disable local simulation of prepare $ dbh-> setAttribute (PDO: ATTR_EMULATE_PREPARES, false ); $ dbh-> exec ('set names gbk');} catch (PDOException $ e) {echo 'database connection failed :'. $ e-> getMessage (); exit;} $ query = "SELECT * FROM news WHERE tid =? "; $ Stmt = $ dbh-> prepare ($ query); $ tid = $ _ GET ['id']; // add the parameter to SQL query $ stmt-> bindParam (1, $ tid); $ stmt-> execute ();?>

Mysql log:

160614 13:14:12       27 Connect    root@localhost on test           27 Query    set names gbk           27 Query    SELECT * FROM news WHERE tid='1'           27 Quit    

It is not found as described: "Setting this attribute to false will not simulate prepare locally"

Php 5.2.17

Additional content:
PDO: ATTR_EMULATE_PREPARES enables or disables the simulation of preprocessing statements. Some drivers do not support or support local preprocessing to a limited extent. Use this setting to force PDO to always simulate preprocessing statements (if TRUE), or try to use local preprocessing statements (if FALSE ).If the driver cannot successfully preprocess the current query, it will always return to the simulated preprocessing statement..
Is it because the driver has not successfully preprocessed the current query?

Reply content:

PDO operation. if the ATTR_EMULATE_PREPARES attribute is set to false, it is found that the prepare is still simulated locally.


  SetAttribute (PDO: ATTR_ERRMODE, PDO: ERRMODE_EXCEPTION); // Set to disable local simulation of prepare $ dbh-> setAttribute (PDO: ATTR_EMULATE_PREPARES, false ); $ dbh-> exec ('set names gbk');} catch (PDOException $ e) {echo 'database connection failed :'. $ e-> getMessage (); exit;} $ query = "SELECT * FROM news WHERE tid =? "; $ Stmt = $ dbh-> prepare ($ query); $ tid = $ _ GET ['id']; // add the parameter to SQL query $ stmt-> bindParam (1, $ tid); $ stmt-> execute ();?>

Mysql log:

160614 13:14:12       27 Connect    root@localhost on test           27 Query    set names gbk           27 Query    SELECT * FROM news WHERE tid='1'           27 Quit    

It is not found as described: "Setting this attribute to false will not simulate prepare locally"

Php 5.2.17

Additional content:
PDO: ATTR_EMULATE_PREPARES enables or disables the simulation of preprocessing statements. Some drivers do not support or support local preprocessing to a limited extent. Use this setting to force PDO to always simulate preprocessing statements (if TRUE), or try to use local preprocessing statements (if FALSE ).If the driver cannot successfully preprocess the current query, it will always return to the simulated preprocessing statement..
Is it because the driver has not successfully preprocessed the current query?

I found the problem. I used the Windows environment. when I used the php5.2.x environment in linux, I could perform preprocessing smoothly.

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.