我正在使用class准备mysql配置设置。我很困惑。我总是使用bindParam。也可以使用数组插入。我的意思是,array和bindparam之间有什么区别。
例如array
$query = $db->prepare("INSERT INTO users SET
username = :uname,
password = :upass,
email = :umail");
$insert = $query->execute(array(
"upass" => "123456",
"umail" => "user@user.com",
"uname" => "username",
));
if ( $insert ){
$last_id = $db->lastInsertId();
}
例如
$stmt = $this -> db_conn -> prepare("INSERT into users(username, password) VALUES(:uname, :upass)");
$stmt -> bindParam(':uname', $username);
$stmt -> bindParam(':upass', $password);
$stmt -> execute();