Do I need to use (int)$id before I use $id in bindValue in Php PDO
I just started using Php Data Objects and one thing I'm not sure about is do I have to validate that some variable is an integer before using it in the query. For example, like this: $id = (int)$_POST['id']; // is this required $query = $pdo->prepare("SELECT * FROM `articles` WHERE `id` = ?"); $query->bindValue(1, $id); $query->execute(); No it's not required for two reasons: You're letting PDO know that you are going to query the database for a column ID. PDO isn't going to parse anything in $_POST['id'] . The second value of bindValue is automatically casted to a string (or of any type you