{"action":"created","issue":{"url":"https://api.github.com/repos/Sammaye/MongoYii/issues/251","labels_url":"https://api.github.com/repos/Sammaye/MongoYii/issues/251/labels{/name}","comments_url":"https://api.github.com/repos/Sammaye/MongoYii/issues/251/comments","events_url":"https://api.github.com/repos/Sammaye/MongoYii/issues/251/events","html_url":"https://github.com/Sammaye/MongoYii/issues/251","id":76410088,"number":251,"title":"Update model after getting it from cache","user":{"login":"Kison","id":2122403,"avatar_url":"https://avatars.githubusercontent.com/u/2122403?v=3","gravatar_id":"","url":"https://api.github.com/users/Kison","html_url":"https://github.com/Kison","followers_url":"https://api.github.com/users/Kison/followers","following_url":"https://api.github.com/users/Kison/following{/other_user}","gists_url":"https://api.github.com/users/Kison/gists{/gist_id}","starred_url":"https://api.github.com/users/Kison/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kison/subscriptions","organizations_url":"https://api.github.com/users/Kison/orgs","repos_url":"https://api.github.com/users/Kison/repos","events_url":"https://api.github.com/users/Kison/events{/privacy}","received_events_url":"https://api.github.com/users/Kison/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-05-14T16:18:46Z","updated_at":"2015-05-15T14:22:41Z","closed_at":null,"body":"I am use caching models in my project, and found that if i try update model after getting it from cache its fields will be rewrote. The reason is that EMongoClient do not have attribute names for ($_meta field in EMongoClient) model that is updated. Now think how best to fix it.\r\n\r\n\r\nSave model to cache:\r\n```php\r\n$model  =  SomeModel::model()->findByPk(someMongoId);\r\nYii::app()->cache->set($cacheKey, $model, self::CACHE_PERIOD);\r\n```\r\n\r\nThis code clears all document fields excepts fields that stored in $_attributes field of model\r\n```php \r\n$model = Yii::app()->cache->get($cacheKey);\r\n// Do some changes with model fields\r\n$model->name = 'Den';\r\n$model->surname = 'Kison';\r\n$model->update();\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/Sammaye/MongoYii/issues/comments/102412416","html_url":"https://github.com/Sammaye/MongoYii/issues/251#issuecomment-102412416","issue_url":"https://api.github.com/repos/Sammaye/MongoYii/issues/251","id":102412416,"user":{"login":"Sammaye","id":323996,"avatar_url":"https://avatars.githubusercontent.com/u/323996?v=3","gravatar_id":"","url":"https://api.github.com/users/Sammaye","html_url":"https://github.com/Sammaye","followers_url":"https://api.github.com/users/Sammaye/followers","following_url":"https://api.github.com/users/Sammaye/following{/other_user}","gists_url":"https://api.github.com/users/Sammaye/gists{/gist_id}","starred_url":"https://api.github.com/users/Sammaye/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Sammaye/subscriptions","organizations_url":"https://api.github.com/users/Sammaye/orgs","repos_url":"https://api.github.com/users/Sammaye/repos","events_url":"https://api.github.com/users/Sammaye/events{/privacy}","received_events_url":"https://api.github.com/users/Sammaye/received_events","type":"User","site_admin":false},"created_at":"2015-05-15T14:22:41Z","updated_at":"2015-05-15T14:22:41Z","body":"Your second comment seems like it could solve all conditions, not just ones where the fields exist in the document explicitly\r\n"}}