Hi,
I am having some columns in db, which are having default value as NULL. When I execute INSERT command, from Mysql workbench/Command Line , it correctly insert 'NULL' for the columns, for which value is not present.
But when I fire same query from yii, it doesn't insert 'NULL', instead it shows blank,
Also one more issue, for DATETIME its inserting '0000-00-00 00:00:00', I want this to NULL, but I am not getting it right.
Page 1 of 1
Mysql Inset Query- Null Issue Query execution from yii doesn't inset default NULL in DB
#2
Posted 25 December 2012 - 02:18 AM
P.A., on 24 December 2012 - 10:06 PM, said:
Hi,
I am having some columns in db, which are having default value as NULL. When I execute INSERT command, from Mysql workbench/Command Line , it correctly insert 'NULL' for the columns, for which value is not present.
But when I fire same query from yii, it doesn't insert 'NULL', instead it shows blank,
Also one more issue, for DATETIME its inserting '0000-00-00 00:00:00', I want this to NULL, but I am not getting it right.
I am having some columns in db, which are having default value as NULL. When I execute INSERT command, from Mysql workbench/Command Line , it correctly insert 'NULL' for the columns, for which value is not present.
But when I fire same query from yii, it doesn't insert 'NULL', instead it shows blank,
Also one more issue, for DATETIME its inserting '0000-00-00 00:00:00', I want this to NULL, but I am not getting it right.
By default Yii check its model class attributes definition first and according to that create a query.and if you have define a datetime field as a null then for sure it will insert value as you have show above.And i guess it will work same in other frameworks too in the case of datetime field.
But if you want to assign that field as a null value then you can change it value like above.
$model->datetime='NULL';
Let it try. I hope it will work here.
CodeSutra
Share this topic:
Page 1 of 1

Help














