nimasdj — 2014-04-24T05:57:11-04:00 — #1
I need some explanation about terminology of ORM and OOP. What do 'domain' and 'model' mean in this area?
ahundiak — 2014-04-24T10:39:41-04:00 — #2
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.
nimasdj — 2014-04-24T11:05:43-04:00 — #3
Thanks for nice explanation.
hall_of_famer — 2014-04-24T14:46:10-04:00 — #4
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