This topic is locked

Using DAL to set field to NULL

6/2/2012 5:04:36 PM
PHPRunner General questions
E
electromotive author

How do you use DAL to write NULL to a datefield?



$tbl = $dal->Table("mytable");

$tbl->Param["rec_id"]=$mykey;

$tbl->Value["some_date"]=NULL; //doesn't work, it writes "0-0-0000" instead

$tbl->Update();


Whereas, this does work.



$sql = "UPDATE `mytable` SET `some_date` = NULL WHERE `rec_id` =".$mykey;

db_query($sql,$conn); //works

// CustomQuery($sql); //does not work, writes "0-0-0000" instead


But I was hoping to convert my SQL to DAL if I could

Sergey Kornilov admin 6/2/2012

At the moment you cannot use DAL to write NULL values to the database.
What you can do is to modify function db_datequotes($val) in include/dbfunctions.my.php file adding a special handling for NULL values.