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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:07:13+00:00 2026-05-12T10:07:13+00:00

I’m creating a calendar application in PHP with CodeIgniter. In the main calendar page,

  • 0

I’m creating a calendar application in PHP with CodeIgniter. In the main calendar page, My model currently creates an array with each index being one day on the current month. That day is an array containing any events the user may have on that day. Now, should I construct the calendar array in the controller FIRST, then pass it to the model so the model can access the database and fill in all the events, or should I just create the calendar array and fill in the events ALL in the model?

$month = array( 'blank', 'blank',  'day1' => array( event 1, event2), 'day2' => ... );
  • 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-05-12T10:07:14+00:00Added an answer on May 12, 2026 at 10:07 am

    That’s a difficult question, and I am not sure everyone would do the same way… But here’s what I think should be taken into consideration :

    • If your Model’s method is to be used from several part of your application (say, the controller that already calls it, a batch-programm, and a SOAP web-service interface), which may means being called from several Controller methods, the question is : what do you want the array to be like ?
      • If it needs to always contain the same thing (“full array”) each time, then, to avoid copy-paste, you should put your code in the Model
      • If it needs to contains the “full thing” only in one case, then, your “special code” can be in the Controller — or in another Model method, that would be called in the Controller, in that special case, and call the existing one to get the data.
      • Another way would be to add one layer, between the Controller and the Model… Might not be such a bad idea, after all…
    • If the array is considered as a “whole” only when the code you’re talking about has been executed, then, I suppose it makes sense to put that code into the Model
    • If that code is part of some Business-logic rule, it has its place in the Model layer ; on the other hand, if it’s only related to presentation, its place would be in the View.
    • If your Model method is called “getData“, it should only return the array containing the “real” data, and not the one containing the “empty” days ; on the other hand, if it’s called “getEventsByDay“, it makes sense to have it return something for each day, even empty ones
    • You should try to have a coherent interface for your Model methods : if the one to save data takes some kind of array, the one the loads the data from your DB should return the same kind of array ; something like $model->save($model->load()) should work, I mean

    In the end, there is no “good answer” : “it depends” ^^

    I don’t really know what I’d do in your case ; I suppose it kinda depends on the rest of the application… The question I’d ask myself is “does the notion of an empty day make sense for my Model, or is it just a matter of presentation ?”

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

Sidebar

Ask A Question

Stats

  • Questions 275k
  • Answers 275k
  • 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
  • Editorial Team
    Editorial Team added an answer The following worked on my system: Install hdf5 version 1.8.4… May 13, 2026 at 2:33 pm
  • Editorial Team
    Editorial Team added an answer It's due to short circuit evaluation. If defined('YII_DEBUG') returns false,… May 13, 2026 at 2:33 pm
  • Editorial Team
    Editorial Team added an answer This is a recipe for disaster. Users don't like programs… May 13, 2026 at 2:33 pm

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I want use html5's new tag to play a wav file (currently only supported
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I've got a string that has curly quotes in it. I'd like to replace
In order to apply a triggered animation to all ToolTip s in my app,

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.