Updating table with a null date

Hy all…

Simple problem: I have a form with a few calendars on it. Sometimes I don’t know the date yet, so, I want the connector to write NULL in the relative database column. Following Stan’s advice I’ve been going crazy following the “complex updates” of the dhtmlxconnector documents but to no avail!

I’ve tried using the example

function my_update($data){
$price = $data->get_value(“price”);
$price = intval($price);
$data->set_value(“price”,“10”);
}

But the whole point is that if it is NULL, THAT’s what I want it to be!

i.e.
function my_update($data) {
$dt1 = $data->get_value(“dt1”);
if($dt1==NULL)
$data->set_value(“dt1”, ??? WHAT ???);
}

i.e. I WANT it to write NULL to db.

I’ve even tried using a dummy date, i.e. 2200-12-31

function my_update($data) {
$dt1 = $data->get_value(“dt1”);
if($dt1==NULL)
$data->set_value(“dt1”, “2200-12-31”);
}

but even that doesn’t work!

The WORST thing is that the validation control on the form doesn’t even work properly. Whether you leave it empty or you put “ketchup” in the date field, it still validates to NULL…

I’ve tried custom validation events, but as I said before there’s no way to distinguish between an empty date and total rubbish!

Can ANYONE help on this, I’ve been on it for 10 days now…

Hi,
please, make sure that my_update is called. You may add the follow code inside to detect it:

function my_update($data){
    die("it works!");
    $price = $data->get_value("price");
    $price = intval($price);
    $data->set_value("price","10");
} 

To set null value you may call:

$data->set_value("price",null);