CActiveForm updates all fields


my question its simple

i have the user table

but in profile form user only can edit email and phone number

my rules:

	public function rules()


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

		// will receive user inputs.


		if(!Yii::app()->user->isGuest) // Profile updating


			return array(

			array('email', 'required'),

			array('email', 'email'),

			array('email', 'unique', 'message' => UserModule::t("This user's email adress already exists.")),

			array('phone', 'length', 'max'=>13, 'min' => 9,'message' => UserModule::t("Incorrect username (length between 3 and 20 characters).")),


when form submit, not only phone and email got update, every user date will be updated


Executing SQL: UPDATE `users` SET `id`=:yp0, `status`=:yp1, `username`=:yp2, `password`=:yp3, `email`=:yp4, `phone`=:yp5, `name`=:yp6, `sex`=:yp7, `birthday`=:yp8, `raffles`=:yp9, `raffletotal`=:yp10, `raffletotalbuy`=:yp11, `membersince`=:yp12 WHERE `users`.`id`='1'

in D:\wamp\www\yii\ecorifa\protected\modules\user\controllers\ProfileController.php (36)

in D:\wamp\www\yii\ecorifa\index.php (22)

does it affect performance by do such unnecessary sets?


If you want to save just come fields use saveAttributes() -


This will work as long as you don’t want to validate the fields or run pre or post save routines. You can aways write a custom update query tailored to your need.

yeah, i read on class docs

a offtopic question:

it is possible use non activerecord querys (DAO) and use it with CActiveForm or other components that require a model?

any way to conver it?