SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict nimasdj's Avatar
    Join Date
    Dec 2007
    Posts
    315
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    terminology of ORM

    I need some explanation about terminology of ORM and OOP. What do 'domain' and 'model' mean in this area?

  2. #2
    SitePoint Guru
    Join Date
    Nov 2003
    Location
    Huntsville AL
    Posts
    692
    Mentioned
    4 Post(s)
    Tagged
    1 Thread(s)
    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.

    PHP Code:
    $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.

  3. #3
    SitePoint Addict nimasdj's Avatar
    Join Date
    Dec 2007
    Posts
    315
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for nice explanation.

  4. #4
    SitePoint Addict bronze trophy Hall of Famer's Avatar
    Join Date
    Apr 2013
    Location
    Ithaca
    Posts
    368
    Mentioned
    6 Post(s)
    Tagged
    2 Thread(s)
    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


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •