如何更新用户信息? (如果用户编辑了他的信息)

Let's assume we are creating a site where people can register with some information (first name, last name, email address, etc.). There must be a way for users to change their information. So user can edit first name field or last name field or both. Please help to find a general and good way for this. I mean if we going to check which field was updated and for each possible case give specific document to mongo's update function is not a good idea, is it?

$employee->update(
    array( '_id' => new MongoId('4ba667b0a90578631c9caea1')),
    array( '$set' => array( 'salary' => '1000' ) )
);

This code will only update the user's salary. But there are too many information. What if user's email or phone number changed? Please help to find a general way.

I would validate my data before building the MongoDB document, then build an array with the validated data, and use the array to build the MongoDB document.

$dataArray = array();
$dataArray['salary'] = '1000';
$dataArray['other_key'] = 'other_val';

$employee->update(
array( '_id' => new MongoId('4ba667b0a90578631c9caea1')),
array( '$set' => $dataArray )
);