I want to insert encrypted password in DB

I class User

function rules




array('username, email, password', 'required'),

array('password', 'default',

'value'=>new CDbExpression(':password', array(':password'=>$this->hashPassword(':password') ) ),

                              'setOnEmpty'=>false, 'on'=>'insert,update'),



it doesn’t work!

can anyone help me?

I wonder if rules allow such a use.

In any case, you can use beforeSave in your model to hash the password. There are many examples here and there.

bennouna is right, you can’t use the rules for that. Take a look at this wiki entry. Simple and useful: http://www.yiiframework.com/wiki/240/authenticating-against-phpass-hashes-with-yii

This has helped,

thanks