yiic.bat problem

I am trying to follow the video blog tutorial , I created the database and models etc via the command line.

So I am trying to create a new user and to save it as the video, I create a new user ($user=new user etc ) but when I set $user->save() the user is not at the database , I do the User::model()->count() and the result is 0.

What  is  wrong?


The insertion may fail because of validation failure. Please check the rules defined in your model.

The email were required also. ;D

[Edit] I see you're fixed lol - oh well this may help someone eventually lol.

Have you defined the safeAttributes yet? By default when you create a model class extending CActiveRecords it should auto make all fields safe attributes that are defined in the DB table, however if they are not for whatever reason, you'll need to make a new:


public fucntion safeAttributes()


    return array(

	'value1, value2, ...',




More than likely however Will is correct and the issue revolves around your rules definition.

If you have defined that certain actions only happen on specific scenarios you have to call that scenario when you call the validate function.


rules …  ('username, password', 'required', 'on'=>'login'),

When you call (in your controller) $model->validate()

You can either do $model->scenario='login'; before that function call or you can do $model->validate('login') as you make the function call.