Last active
December 30, 2017 16:15
-
-
Save lamngockhuong/ebd6b8060151edecc834d7c62d12d330 to your computer and use it in GitHub Desktop.
[PDO: Sự khác nhau giữa bindValue và bindParam (Xem ví dụ để thấy sự khác nhau)] #php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$sex = 'male'; | |
$s = $dbh->prepare('SELECT name FROM students WHERE sex = :sex'); | |
$s->bindParam(':sex', $sex); // use bindParam to bind the variable | |
$sex = 'female'; | |
$s->execute(); // executed with WHERE sex = 'female' | |
or | |
$sex = 'male'; | |
$s = $dbh->prepare('SELECT name FROM students WHERE sex = :sex'); | |
$s->bindValue(':sex', $sex); // use bindValue to bind the variable's value | |
$sex = 'female'; | |
$s->execute(); // executed with WHERE sex = 'male' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment