Today's Question:  What does your personal desk look like?        GIVE A SHOUT

 ALL


  A trap in PDOStatement::bindParam

First, let's check out below codes:<?php$dbh = new PDO('mysql:host=localhost;dbname=test', "test"); $query = <<prepare($query); $bind_params = array(':username' => "laruence", ':password' => "weibo");foreach( $bind_params as $key => $value ){ $statement->bindParam($key, $value);}$statement->execute();What is the SQL executed finally? Is there any problem with above codes?Many people may think the query executed is :INSERT INTO `user` (`username`, `password`) VALUES ("laruence", "weibo");But the query actually gets executed is :INSERT INTO `user` (`username`, `passwor...

9,165 1       PHP TRAP BINDPARAM