1. Model — should hold data only and delegate methods such as save() or find() to the storage. Shouldn't be aware of storage used. This way we'll be able to create general purpose components that are able to work with models and will not depend on the data storage.
2. Storage — should provide methods to save model, find model etc. Storage is DB-specific:
Storage
SQLStorage
MySQLStorage
MSSQLStorage
KeyValueStorage
RedisStorage
ObjectStorage
MongoDBStorage
Since some storages are providing specific ways to work with data, we may expose these in specific classes.
3. Results collection — a traversable collection that's returned from query methods.
Post::model()->into('PostCollection')->findAll();Possible usage is to create good looking API for related models management:
$tag = new Tag(); $tag->name = 'Yii'; $post = Post::model()->findByPk(1); // add will save $tag into $forSaving array so AR will save just this one instead of deleting-saving every tag out there $post->tags->add($tag); $post->save();

Help
This topic is locked














