How to remove field in insert and update sql command?

I have table in PostgreSQL:


    id              serial          PRIMARY KEY,

    user_id         integer         NOT NULL        REFERENCES users(id),

    time            timestamp       NOT NULL        DEFAULT(CURRENT_TIMESTAMP),

    title           text            NOT NULL,

    content         text            NOT NULL


and model class generated automatically by yiic shell / model news:

class news extends CActiveRecord



I added beforeSave() function to fill the user_id field, but I have problem with time field.

The INSERT operations looks like:

INSERT INTO news("user_id", "time", "title", "content") VALUES(…);

How can I remove certain filed (time) from insert and update commands (or past there DEFAULT) ??


you should do it, in your model, in method rules().

check rules

and then do something like this:

public function rules()


	return array(


                	'news_time', 'default',

	                'setOnEmpty'=>true,'on'=>'insert, update',




it works, thx :)