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 ...