Issue in storing auto generated password to DB

Hi ,

I have an issue in storing auto generated to DB. Save()is unsuccessful.

Please help.



Creating default object from empty value (C:\xampp\htdocs\mylls1\protected\controllers\homeController.php:89)

User.php [/b]

// model//

public function rules()


	// NOTE: you should only define rules for those attributes that

	// will receive user inputs.

	return array(

	    array('email, password','required','on'=>'create'),	



		array('email,  password', 'length', 'max'=>256),

		array('email', 'unique'),

		array('password', 'compare'),

		array('fname,lname, password_repeat', 'safe'),

		// The following rule is used by search().

		// Please remove those attributes that should not be searched.

		array('id, email,  password, fname,lname', 'safe', 'on'=>'search'),



// Controller Code //

                            $model2=new User('instant_create');


			// Auto password creation// 

                            $length = 10;

			$chars = array_merge(range(0,9), range('a','z'), range('A','Z'));


			$password = implode(array_slice($chars, 0, $length));




			[b] $model->password= md5($password);[/b]



Side Note:

If I remove password from model and controller , I can store rest of the attributes successfully.

Could it be this rule:

array('password', 'compare'),


Maybe dump the errors after you do the save to see why it’s unhappy?


There was typo

$model->password= md5($password); Should have been $model2->password= md5($password);

print_r($model2->getErrors()); is awesome…helped me pinpoint the error…+1