What exactly does bindValue do in php? I have managed without, but I should have used it, why is it absolutely necessary?
Example:
$sth->bindValue(':id', $id, PDO::PARAM_INT);
What exactly does bindValue do in php? I have managed without, but I should have used it, why is it absolutely necessary?
Example:
$sth->bindValue(':id', $id, PDO::PARAM_INT);
bindValue binds a value to a named placeholder in a SQL statement, it's better to use this form for perfomance and security, also with this method you can tell what type of data is expected. So in your exemple, you're saying that "$id" is the value of ":id" et the data type expected is a INT.