Created
September 11, 2012 04:25
-
-
Save ajcrites/3695946 to your computer and use it in GitHub Desktop.
Unnamed vs. Named prepared statements in PDO
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
//UNNAMED | |
$query = "SELECT userid FROM t1 WHERE (username = ? OR useremail = ?) | |
AND usertoken = ?"; | |
$prepared_statement = $db_connection->prepare($query); | |
$prepared_statement->execute(array($_POST['login'], $_POST['login'], | |
$_POST['token']) | |
); | |
//NAMED | |
$query = "SELECT userid FROM t1 WHERE (username = :login | |
OR useremail = :login) AND usertoken = :token"; | |
$prepared_statement = $db_connection->prepare($query); | |
$prepared_statement->execute(array('login' => $_POST['login'], | |
'token' => $_POST['token']) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment