Scryii
(Dirk Gollnick)
January 15, 2011, 7:41pm
1
Hi,
I only want to save my record.
One paramter should be NULL
Using:
[indent]
$bw->comment = NULL;
[/indent]doesn’t work
Trying set attribute
[indent]
$bw->setAttribute('comment', NULL);
[/indent]also doesn’t work.
Where am I wrong ?
(Comment is a colum of the AR class, $bw is an instance …)
Thx.
Scryii
[indent] [/indent]
I don’t know if this makes a difference, but I save null values successfully by assigning the value to ‘null’ in all lower-case.
Make sure that you don’t overwrite the attributes before you save them with something like
$model->attributes=$form->attributes;
Also make sure the database ‘column’ field is set to receive NULL values.
Hope that helps
jayrulez
(Waprave)
January 15, 2011, 8:49pm
3
Hi,
I only want to save my record.
One paramter should be NULL
Using:
[indent]
$bw->comment = NULL;
[/indent]doesn’t work
Trying set attribute
[indent]
$bw->setAttribute('comment', NULL);
[/indent]also doesn’t work.
Where am I wrong ?
(Comment is a colum of the AR class, $bw is an instance …)
Thx.
Scryii
[indent] [/indent]
Does your database table schema allow for you to save a null value? do your validation rules in your model allow for the value to be null? do you get any error/validation error message when you try to save the record?
Scryii
(Dirk Gollnick)
January 16, 2011, 7:19pm
4
Thx. for your ideas.
Sometimes it is really easy.
I changed the database and allowed ‘null’ AFTER generating the Model class by using gii.
I used gii and generated the model class again => and everythink is perfect
Scryii