Bound column, column King's dispute account binding _php Tutorial

Source: Internet
Author: User

Bound column, column King's dispute account binding


 PhpTry{        $DBH=NewPDO (' Mysql:dbname=testdb;host=localhost ', ' mysql_user ', ' mysql_pwd '); $DBH->setattribute (Pdo::attr_errmode, PDO::errmode_exception); }Catch(pdoexception$e){        Echo' Database connection failed: '.$e-GetMessage (); Exit; }//declare a SELECT query to get information about the four fields of the D01 Department from table ContactInfo    $query= "Select UID, name, phone, email from contactinfo WHERE departmentid= ' D01 '"; Try {        $stmt=$DBH->prepare ($query);//prepare a statement for a good query        $stmt->execute ();//execute a prepared query        $stmt->bindcolumn (1,$uid);//bind variables by column position offset $uid        $stmt->bindcolumn (2,$name);//bind variables by column position offset $name        $stmt->bindcolumn (' phone ',$phone);//bind the column name to the variable $phone        $stmt->bindcolumn (' email ',$email);//bind column names to variables on the         while($stmt->fetch (Pdo::fetch_bound)) {//the Fetch () method passes in a specific parameter traversal            Echo $uid." \ t ".$name." \ t ".$phone." \ t ".$email." \ n ";//The output automatically assigns the value of the column value to the corresponding variable        }    } Catch(pdoexception$e) {        Echo $e-GetMessage (); }

http://www.bkjia.com/PHPjc/1075861.html www.bkjia.com true http://www.bkjia.com/PHPjc/1075861.html techarticle binding column, column King's dispute account binding? php try {$dbh = new PDO (' Mysql:dbname=testdb;host=localhost ', ' mysql_user ', ' mysql_pwd '); $DBH-set Attribute (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.