Problems related to the return value of PDO: exec ()

Source: Internet
Author: User
PDO: exec () returned value. // Set the script running time to set_time_limit (0); // use PDO to create a pgsql connection try {$ pgLink = newPDO ('pgsql: host = localhostport = 5432 dbname = db2user = root PDO: exec () returned value.
// Set the script running time to unlimited
Set_time_limit (0 );

// Use PDO to create a pgsql connection
Try {
$ PgLink = new PDO ('pgsql: host = localhost port = 5432 dbname = db2 user = root password = 661 ');
} Catch (Exception $ e ){
Echo $ e-> getMessage ();
}

// Define the SQL modification statement
$ SQL = "UPDATE trade. membership SET gender = 1, birth_type = 0, name = 'wsy', birthday = '2017-01-01 ', email = '', join_date = '2017-01-02 ', status = 1, address = 'AAA', id_number = '000000', postcode = '000000', phone = '000000', type_id = 1 WHERE mobile = '000000 ';";

// Execute the SQL statement
$ Result = $ pgLink-> exec ($ SQL );

// Output SQL results
Echo $ result. ''. $ SQL;

Output result:
1 UPDATE trade. membership SET gender = 1, birth_type = 0, name = 'wsy', birthday = '2017-01-01 ', email = '', join_date = '2017-01-02 ', status = 1, address = 'AAA', id_number = '000000', postcode = '000000', phone = '000000', type_id = 1 WHERE mobile = '000000 ';

The problem is as follows:
There is no row of mobile = '000000' in this table at all. getting the $ SQL statement to the local SQL server is also "0 affected rows ".
But why is the result in the program "1 "? Shouldn't the output result of PDO: exec () be the number of affected rows added, deleted, and modified?

------ Solution --------------------
This should be a pdo bug, which can be correctly handled by preprocessing and then using PDO: rowCount.

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.