You need to use bindValue
, not bindParam
bindParam
takes a variable by reference, and doesn't pull in a value at the time of calling bindParam
. I found this in a comment on the PHP docs:
bindValue(':param', null, PDO::PARAM_INT);
P.S. You may be tempted to do this bindValue(':param', null, PDO::PARAM_NULL);
but it did not work for everybody (thank you Will Shaver for reporting.)