MDB : inserting NULL timestamp
| From: | Vincent DUPONT | Date: | Thu, 01 Jul 2004 15:16:38 +0000 |
| Subject: | MDB : inserting NULL timestamp | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-13442@lists.php.net to get a copy of this message | ||
Hi,
I use MDB to insert a timestamp into a MS SQL table.
If the timestamp is non empty, ok
if the timestamp value is empty, I would like to insert a NULL rather than a '', because
MSSQL encodes the default 01/01/1900
The Common.php reads :
function getTimestampValue($value)
{
return(($value === NULL) ? 'NULL' : "'$value'");
}
So, I tried to check if the php value I want to insert is empty or not. If empty, then assign it the
php NULL
if(trim($value)=='') then value= NULL;
But This does not work. The 01/01/1900 is always inserted with empty dates
Did I miss something?
Note : I use a prepared query inside another class, so i cannot directly use the setParamNull()
function to set the NULL value to the prepared query
Thank you ,
Vincent