Bind a column, bind a dispute account of the column king _ PHP Tutorial

Source: Internet
Author: User
Bind the column to the dispute account of the column King. Bind the column to the dispute account of the column King? Phptry {$ dbhnewPDO (mysql: dbnametestdb; hostlocalhost, mysql_user, mysql_pwd); $ dbh-setAttribute (PDO: ATTR_ERRMODE, PDO: ER binding column, dispute account binding of column King
 SetAttribute (PDO: ATTR_ERRMODE, PDO: ERRMODE_EXCEPTION);} catch (PDOException $ e) {echo 'database connection failed :'. $ e-> getMessage (); exit;} // declare a SELECT query. obtain the information of the four fields of D01 from the contactInfo table. $ query = "SELECT uid, name, phone, email FROM contactInfo WHERE initialize mentid = 'd01' "; try {$ stmt = $ dbh-> prepare ($ query ); // prepare a declared query $ stmt-> execute (); // execute the prepared query $ stmt-> bindColumn (1, $ uid ); // bind the variable $ uid $ stmt-> bindColumn (2, $ name) through the column position offset ); // bind the variable $ name $ stmt-> bindColumn ('phone', $ phone) through the column position offset ); // bind the column name to the variable $ phone $ stmt-> bindColumn ('email ', $ email ); // bind the column name to the variable $ email while ($ stmt-> fetch (PDO: FETCH_BOUND) {// The fetch () method transmits a specific parameter to traverse echo $ uid. "\ t ". $ name. "\ t ". $ phone. "\ t ". $ email. "\ n"; // The output automatically assigns the column value to the value of the corresponding variable} catch (PDOException $ e) {echo $ e-> getMessage ();}

Why? Php try {$ dbh = new PDO ('MySQL: dbname = testdb; host = localhost', 'MySQL _ user', 'MySQL _ pwd '); $ dbh-setAttribute (PDO: ATTR_ERRMODE, PDO: ER...

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.