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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:04:05+00:00 2026-06-09T10:04:05+00:00

After reading a fair few posts on Stack, and also some material recommended to

  • 0

After reading a fair few posts on Stack, and also some material recommended to me on line, the MVC pattern is quite open to interpretation, so please don’t answer with another explanation. Thanks!

I’m reaching the end of designing my own PHP MVC now, and have two possible ways to move forward with the views.

But first, my controllers are currently quite dumb, not containing any classes and simply call public methods from the suitable models, and render the appropriate view.

Views are included as necessary, so naturally the objects are available to them via the constructors, along with all the methods (inc delete/update etc).

My first option is to get data using something like this in the view

foreach($object->fetchData() as $data)  

and then looping through the results. However some people do not agree with this, and have suggested that such methods should be excluded from the view. Instead it has been recommended that I assign this to a variable in the constructor, and then use this variable in the view

//constructor
$fetched_data = $object->fetchData()

// view
foreach($featched_data as $data)

I don’t like this very much, as it seams messy and unnecessary.

With all my critical methods being made available to the view, could this be considered a problem?

So here’s the question. Do I keep it how it is, and create new methods in the MODEL for rendering data (as above) OR can I create a class in the constructor, extend the model into it, protect the critical functions in the model, and then create my read only public methods in the CONSTRCUTOR?

Thanks!

  • 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-09T10:04:08+00:00Added an answer on June 9, 2026 at 10:04 am

    I would create a class in the constructor. Not only would extending the model be a much safer approach, but it’d also minimize the calling of functions in the views. Am assuming you’ll have several views, it’s much easier to get access the constructor data than calling method functions each time in each view.

    You can add classes to your controllers that will call the method functions and pass the data directly into the views, instead of clustering your constructor or bootstrap.

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

Sidebar

Related Questions

After reading some posts, it seems like you can open a file for both
After reading some posts like this one: Choose File Dialog It appears that Android
After reading a few posts and reading on the developers page about ASYNCTASK, I
After reading this question, I need to clear up some things. IQueryable<Customer> custs =
E-Texteditor recently announced going open-source with their open company model. However after reading through
After reading RailsGuides , some answers here and other docs I am still confused
After reading some statistics about my app I saw that it takes over one
After reading a bunch of stackoverflow posts and forums I got really confused on
After reading some reports about the inadequacies of the Mono 2.6 garbage collector, I
After reading some threads on misuses of exceptions (basically saying you don't want to

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.