I would like to know if when I use the queries for SQL commands with PDO I need to use bind()
:
$SQL->bindValue(1, $email, PDO::PARAM_STR); // Seria algo assim?
For example in this case:
$searchSQL = $pdo->prepare('SELECT email,senha FROM tbl_usuario WHERE email = ?');
$searchSQL->execute(array($email));
I should insert that line, before execute()
or not:
$searchSQL = $pdo->prepare('SELECT email,senha FROM tbl_usuario WHERE email = ?');
$searchSQL->bindValue(1, $email, PDO::PARAM_STR); Eu uso ela?
$searchSQL->execute(array($email));
Because searching the internet I saw that I can do SQL queries using queries or psedonimos:
$searchSQL = $pdo->prepare('SELECT email,senha FROM tbl_usuario WHERE email = ?');
$searchSQL = $pdo->prepare('SELECT email,senha FROM tbl_usuario WHERE email = :email');
But in videotape, the boy only uses bind()
when he used it like this:
$searchSQL = $pdo->prepare('SELECT email,senha FROM tbl_usuario WHERE email = :email');
$searchSQL->bindValue(1, $email, PDO::PARAM_STR);
Is there any problem with using the questions? And taking advantage of the topic, the third parameter PDO::PARAM
, is it specific to the type of the variable?
For String I use PDO::PARAM_STR
, For INT I PDO::PARAM_INT
and so on or not?