I need some explanation about terminology of ORM and OOP. What do 'domain' and 'model' mean in this area?
That is a pretty broad question but here is a beginning of an answer.
First, don't separate domain and model. Instead, think in terms of a domain model which tries to represent whatever problem you are trying to resolve.
For example, in my sports game schedule system I have a Game object. A Game has 2 or more teams as well as 0 or more officials. So my domain model consists of Game, GameTeam and GameOfficial objects. These are simple plain php objects which contain some business logic.
I need to store games in a sql database. That is where an ORM layer comes in. By setting up some mapping files, I can save Game to a games table, GameTeam to a game_teams table etc and perserve the relations between them. Another object called GameRepository provides the link between my application and the database.
$game = $gameRepository->find(1);
echo $game->getHomeTeam()->getName(); // Echos the name of the home team for game #1.
$games = $gameRepository->findAllGamesForTeam('Auburn Tigers');
This of course is just the tip of the iceberg but maybe it will help.
Thanks for nice explanation.
Well 'domain' is actually just a synonym for 'business', to many people domain logic = business logic and domain model = business model. Model is a bit more difficult to explain, its an object with identity and the object in which the business logic come from. Hopefully this clears up your confusion, its indeed hard to grasp at times. XD
This topic is now closed. New replies are no longer allowed.