$id can but is not necessarily NULL.  Other than using PHP to test $id for NULL, and changing the query to IS NULL, how can this query be performed?
$stmt = $db->prepare("SELECT * FROM t WHERE id=?");
$stmt->execute([$id]);
return $stmt->fetchAll();
Per https://stackoverflow.com/a/1391801/1032531, I tried bindValue(':id', null, PDO::PARAM_INT);, but get error Fatal error: Cannot pass parameter 2 by reference
I've also tried $stmt->bindParam(':id', $id, PDO::PARAM_NULL);, and while no error, I get no results.
 
     
     
    