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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:05:35+00:00 2026-05-28T17:05:35+00:00

Where should intermediate code be placed? (something that ins’t just storing/retrieving data from DB

  • 0

Where should intermediate code be placed? (something that ins’t just storing/retrieving data from DB nor processing requests/views)

For example,

Say I have Listings and I create CRUD functions in the model. These Listings may require more complex tasks such as pausing and resuming, which may require some time calculations, error setting, etc. Should these be placed in the model or should I wrap a simple model in a library and use that as a middleman for the model?

At the moment I’m thinking of using Drivers/Libraries and keeping models rather simple, except for some dynamic SELECT filters. I’m getting a bit confused though, since I’m guessing I’d probably have to recheck variables, dependencies, etc in the model after doing it in the library, yes?

I’d most likely either squish everything together in the model and check once or separate and check twice?

  • 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-28T17:05:36+00:00Added an answer on May 28, 2026 at 5:05 pm

    The general rule of thumb is:

    1) Perform all business logic in the models.

    2) Perform actions like a traffic cop would in controllers. (directing users to new views based on results of activities.)

    3) Perform only presentational logic in views.

    Anything else that you would like to do that would be considered, “intermediary”, could reside in a Library or Helper.

    It should be noted though that if you write a Library, don’t forget to get an instance of the current CI object in your class so that you have it to use with your internal class methods.

    class Your_lib {
      $CI =& get_instance();
      ...
    }
    

    Hope that helps.

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

Sidebar

Related Questions

While processing multiple gigabyte files I noticed something odd: it seems that reading from
Should I still be using tables anyway? The table code I'd be replacing is:
Should libraries that the application relies on be stored in source control? One part
Context: The structure of the code is that a WCF service (server-size) talks to
Good morning - I'm an intermediate-level developer who wants to build on online data-driven
I have to work with some code that isn't truly MVC (i.e., it doesn't
Excel provides the Subtotal option from the Menu Data -> Outline -> Subtotal .
I'm going through Intermediate Perl and it's pretty cool. I just finished the section
I have a piece of .NET code that is erroring out when it makes
I am working on a toy language that uses C++ as an intermediate language,

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.