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

  • SEARCH
  • Home
  • 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 8100897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:51:28+00:00 2026-06-05T22:51:28+00:00

In my application I have Users, Organisations and Employees. There are domain objects for

  • 0

In my application I have Users, Organisations and Employees. There are domain objects for each of these, and database mappers.

When a User initially sets up an Organisation, I want to automatically create an Employee record for that User/Organisation combination. (The type of record will be Owner). Basically this comes down to two database inserts: one for Organisation, the other for Employee.

I can see two ways to go about this:

  1. The controller can create the new Organisation object and use a mapper, orgMapper::insert($newOrg), to persist it. With that done it can then create the new Employee object and again use a mapper, employeeMapper::insert($newOwner), for persistence.
  2. The controller can create the new Organisation object, and this object does the rest of the work itself. It would call orgMapper::insert($this), and with the key which is returned would then create and persist the new Employee object.

There seems to be a number of benefits in the second approach: the business logic (i.e. an employee/Owner record for each new Organisation) is embedded in the model, and the controller is skinnier. The only reason I hesitate is that this means my domain is becoming dependent on my mapper.

I would use a factory in the domain to get the mapper, so all coupling would come down to a single point. Does this make the dependency acceptable? Or do I have a deeper design issue?

I have read a bit about a service layer. Perhaps this is where I should be looking?

I am using PHP and Zend Framework

Your thoughts are much appreciated. My cat and I have exhausted our own ideas…

  • 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. Editorial Team
    Editorial Team
    2026-06-05T22:51:30+00:00Added an answer on June 5, 2026 at 10:51 pm

    Since I am not a ZF user (and have been avoiding it), maybe my solution would not apply.

    Data mappers are not supposed to work with just a single table in database. Instead, when you are storing the new Organization entry (and i guess the Organization instance contains a collection of Employee objects), the mapper also should create all the entries for the Employees, and the accompanying data in OrganizationEmpoyees table.

    The short answer: neither, storage is responsibility of mapper.

    If I misunderstood the DB structure, and how it relates to “(..) Employee record for that User/Organisation combination” and the the Employee domain objects are completely separate from Organization, then the 1st of your solutions would be acceptable.

    As for adding service on top of domain objects and mappers, that would be a good idea. Because you have been leaking domain logic inside the controller already. Seems like a bad thing to do.

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

Sidebar

Related Questions

In my web application I will have users, each user will have albums, and
I am creating a web application that will have many users. Each user has
In my web application we have many users.I want to set permission for each
I have an application with multiple users with different roles. Each users access to
I have a bunch of objects in my application (Organisations, Individuals, Orders, etC) and
In my web application users have the ability to upload games which are then
I have an application with Users, Machines, and Tests. Users have many Machines and
In my web application, I have users input a date in a simple textbox.
my application may have more then one users on the same phone, and i
When no users have the any pages in an application open, it will unload

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.