DDD and MVC: Difference between 'Model' and 'Entity'

后端 未结 5 707
夕颜
夕颜 2020-12-12 11:27

I\'m seriously confused about the concept of the \'Model\' in MVC. Most frameworks that exist today put the Model between the Controller and the database, and the Model alm

5条回答
  •  借酒劲吻你
    2020-12-12 11:47

    A simple solution using service and collection:

    findAllByDateRange('within 30 days');
            while($postCollection->getNext()) {
                echo $postCollection->current()->getAuthor();
            }
        }
    }
    

    EDIT: The model(class) is the simple representation of the entity scheme. The model(object) is a single entity. The service operates on models and provides concrete data to the controllers. No controller has any model. The models stand alone.
    On the other "side", mappers map the models into persistance layers (e.g: databases, 3rd party backends, etc).

提交回复
热议问题