1
I wonder 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 must insert that line before the 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 video class, the boy only uses bind()
when he wore like this:
$searchSQL = $pdo->prepare('SELECT email,senha FROM tbl_usuario WHERE email = :email');
$searchSQL->bindValue(1, $email, PDO::PARAM_STR);
Is there a problem with using the question marks? And taking advantage of the topic, the third parameter PDO::PARAM
, it is specific to the type of the variable?
To String i use PDO::PARAM_STR
, To INT me PDO::PARAM_INT
and so on or off?
Interrogations are more interesting when you have conditions (usually
where
) dynamics. In the link has some explanations and other links to specific parts.– rray