Hi all.
I can't figure out how to get NULLs into MySQL date columns using prepared statements. Neither an empty string nor "NULL" result in a null entry in the DB; the columns wind up with 00-00-00 dates. There's no default value set on the column in the DB, nulls are allowed, and other rows (test data added with plain SQL statements) do contain nulls for the dates.
Any ideas? Thanks!
How do we get NULL into date columns w. prepared statements?
Moderator: General Moderators
-
Stokestack
- Forum Newbie
- Posts: 14
- Joined: Thu Sep 16, 2010 2:37 am
Re: How do we get NULL into date columns w. prepared stateme
You need to bind real null:Stokestack wrote:Neither an empty string nor "NULL" result in a null entry in the DB; the columns wind up with 00-00-00 dates.
Code: Select all
// ...
$date = null;
$stmt->bind_param('s', $date);
$stmt->execute();