Reputation: 11275
I have an SQL query that goes like this:
$stmt = $dbh->prepare("SELECT userID FROM User WHERE areaCode=? AND contactNo=?");
$stmt->bindValue(1, $areaCode ? $areaCode : null, PDO::PARAM_INT);
$stmt->bindValue(2, $contactNo, PDO::PARAM_INT);
$stmt->execute();
When $areaCode is null
, this query would fail because areaCode=null
needs to be tested with areaCode IS NULL
instead. Is it still possible to parameterized such query?
Upvotes: 0
Views: 145