$model->save() and arrays

Hi,

an CActiveForm includes textfields and checkboxes.

If the user submits (using POST) the form, the data-processing starts: $model->validate and (if validation is true) $model->save().

(Unfortunately) The form puts the selected values of an checkbox into an array (by default).

So if i use $model->save(); the method doesn’t serialize the array and simply writes “ARRAY” into the mysql column.

Is there any Yii feature to solve this behaviour?

Or may I have to use onBeforSave() to serialize and onAfterFind() to unserialize?

2nd question: one database column is an "timestamp". So mysql has to set the current timestamp if an record is inserted. Using $model->save() also writes the timestamp, even it is empty (results in: 0000-00-00 00:00:00).

Is there a way to avoid the writing of special/specific columns?

Thank you!

Best regards,

rall0r

cant help you with the 1st question

the 2nd one, it is mysql that does it by default

Hey Gustavo,

by default mysql inserts the current time stamp if the column is not specified by an "insert into" or "update"

But yii sets the time stamp attribute as an empty value:


UPDATE `such_sets` SET `ID`=:yp0, `timestemp`=:yp1,

[...]

 Bound with :yp0='1', :yp1='' [...]

So the question is, is it possible, that yii doesn’t save an empty attribute.

greetings