Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 87681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:26:27+00:00 2026-05-10T22:26:27+00:00

I asked this question a while back but now I’m looking to implement an

  • 0

I asked this question a while back but now I’m looking to implement an actual separation between my database access layer and the domain layer. I am also going to be working to move business logic into the domain where it belongs and out of the controller scripts.

I’m using Zend Framework which implements the Table Data Gateway and Row Data Gateway patterns for the data access layer, but it apparently fails to really define how to build a domain layer that is separate from the data access layer. I’ve considered using an Active Record pattern where the domain logic coexists with the data access logic, but I have the following situation that occurs at least once that I don’t think Active Record will handle:

I have a single table ‘Person’ which contains person_id and userType fields.

Each userType (admin, buyer, associate, supervisor) has specific business logic associated with it and all types inherit some basic functionality from a Person object.

I don’t want to bloat the Row Data Gateway object with business logic that belongs specifically to just one type of user but I’m not certain how to construct the domain layer to represent the different types of users. For example, do I make a Person object that contains the PersonGateway object and then write wrapper functions that pass calls to the gateway object, or do I write the Person object to extend the PersonGateway object and then only implement the specific functions that I need?

Likewise, I would typically think that this is (in part) a factory problem where I need a factory method that will instantiate the correct sub-class based on userType. Is that still the best method here with Zend Framework’s Zend_Db class?

Any suggestions or links to tutorials that talk about how to properly create a domain model on top of Zend_Db would be greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T22:26:28+00:00Added an answer on May 10, 2026 at 10:26 pm

    Domain Models extend nothing. They’re just plain classes you use to encapsulate business logic. They may use data access objects, so there may be a protected instance of a row data gateway object inside the class. A Row object usually represents an instance of the domain more closely than a Table object. Besides, you can always get the Table object with the Row‘s getTable() method.

    Typically DM classes have an interface with methods corresponding to higher-level operations you can do with that class. But you don’t necessarily want to surface all data access operations.

    class Person {   // Zend_Db_Table_Row object   protected $data;     public function subscribeToService(Service $service) { ... }    public function sendMailTo(Person $recipient) { ... }    public function changePassword($newPassword) { ... } } 

    I also blogged about this subject last spring, and wrote about it on the ZF mailing list recently.

    As far as tutorials and resources, try http://domaindrivendesign.org/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 60k
  • Answers 61k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer No; you shouldn’t cast the result, since: It is unnecessary,… May 11, 2026 at 9:35 am
  • added an answer If you need to share ressources between web application you… May 11, 2026 at 9:35 am
  • added an answer In your concrete case you should just add Type =… May 11, 2026 at 9:35 am

Related Questions

I asked this question a while back but now I'm looking to implement an
I get asked this question a lot and I thought I'd solicit some input
I was asked this question in a job interview. The interviewer and I disagreed
When I asked this question I got almost always a definite yes you should
I just asked this question . Which lead me to a new question :)
I recently asked this question and worked out that the reason a single email
I've asked this question over on the MSDN forums also and haven't found a
this question is an extension to a previous question i asked (and was answered).
This is a question I asked on another forum which received some decent answers,
In this question, I asked about breaking a dataset into subsets, and got a

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.