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 8480397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:17:03+00:00 2026-06-10T19:17:03+00:00

If making things work is only requirement, we can put all controlling login and

  • 0

If making things work is only requirement, we can put all controlling login and DB handling logic even in the views & it will work. However this is not a right approach for reusable design.

Before I ask my real design question, below is my current understanding about separation of responsibilities in terms of model.

  • All Database related code, even db related logic, should go in models.
  • For a table, say ‘my_tab’, propel generate 4 classes, out of which only 2 classes ‘MyTab.php’ and ‘MyTabPeer.php’ should be edited.
  • MyTabPeer.php must only have data fetching.
  • Any logic, if required to fetch data, should go in ‘MyTab.php’

This is simple and I hope it is correct, if not, please correct me.

Now, I have a special condition. I’ve 4 tables, say a, b, c, d. For that, propel generated 8 editable classes (excluding base*.php)

A.php    APeer.php    B.php    BPeer.php
C.php    CPeer.php    D.php    DPeer.php

One page of my application, shows Mailbox (say). Mailbox is not a table in database but it gets its data from complex join query between above 4 tables along with lot of calculation/conditions.

I generated that query, fetch data from it and displayed it. Mailbox is running as expected. However I did it in my controller (action class), which I know is not a right place for that.

My question is, where should I put that code? Possible options:

  • Controller, I think, is not a right place for DB logic/fetch.
  • I’ve 8 model classed however data do not belong to any one of them but as combination of them all.
  • A separate helper/lib, but I know I’ll never reuse that code as its unique page of the site.
  • Anywhere else?

Please suggest if I’m wrong but I guess I should put it in models as it is fetching data. Since A is primary table, I probably should put code in A.php and APeer.php. If that is correct place, next question is, What should go in A.php & what should go in APeer.php? I’ve following operations to do:

  • Some logic to decide what columns, should I select.
  • As like mailbox, I can show received/sent message. Controller will tell what to show but there are some db logic to set conditions.
  • Then really fetch data from complex Join query.
  • Returned data will have all rows but I might need to merge few rows conditionally.

As per my understanding, Point 3 should go in APeer.php and rest in A.php. Is my understanding correct?

  • 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-10T19:17:04+00:00Added an answer on June 10, 2026 at 7:17 pm

    You should create separate model class i.e. Mailbox.
    Method of this model should do the complex select and return data to your action in controller. This solution will not break MVC approach.

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

Sidebar

Related Questions

Basically I'm making a list view that you can add things to the top
We all know you can't do things like this: int a = 7; new
We are making a website for a client at work, which can be found
I have this simple code (for making things shorted, the important bits are probably
I am using Git Bash and am trying a few things like making a
I am making an API for some AJAX related things in my web app
I'm making an app where I have different things: images, videos,a viewController(.h and .m)
I basically want to make things easier by just looping LinkButtons instead of making
im making some script with mechanize.browser module. one of problem is all other thing
I am making an installer in java swing it almost completed only one thing

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.