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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:43:29+00:00 2026-05-23T14:43:29+00:00

I’m having some trouble understanding how codeigniters loading works. Well first you have the

  • 0

I’m having some trouble understanding how codeigniters loading works.

Well first you have the autoload which seems pretty straight forward, it loads everything everytime. So this sounds good to use for the stuff I use all the time.

Second you can load everything inline. But here is my question: How long does it stay loaded?

Let say I load the form validation library in the controller, then I load the model, can I use the form validation in the model or do I have to reload it again?
Continuing let say I load a view and another controller, can I use the form validation? Or do I need to load?
After a redirect?
How about if I load a model or helper instead of a library?
Let say I want to use a model inside another model, where do I load that one?

So the basic question, how long or rather how far does the load go before I need to reload?

  • 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-23T14:43:29+00:00Added an answer on May 23, 2026 at 2:43 pm

    The loading, as @yi_H correctly pointed out, lasts for all the current script lifetime. I.E. when you’re calling a controller’s method, the resource is loaded. If you call the same resource inside another method, that isn’t available anymore.

    That happens because controller are initialized at each request, so when you access
    index.php/mycontroller/method1 the controller is initialized (you can enable logs and see this clearly). In your method you load, say, the html helper.
    If you then access index.php/mycontroller/method2, and it also requires the html helper, but you didn’t load it intro the method, you will get an error of function not found.

    So, basically, if you want to have the same resource always available you have 3 choices:

    1. autoload it in application/config/autoloader.php
    2. load it at every request, i.e. inside each method that will be using that resource
    3. put it inside the controller’s constructor, so to have it always initialized at each request.

    It’s more or less the same as autoloading, except that it can work only for the controller which you put the constructor in, so you get a benefit when you don’t want something to be loaded at EACH controller (like when you use autoloading) but only on a few.
    In order to use this last method, remember to CALL THE PARENT CONSTRUCTOR inside your controller (like you do normally with models):

    function __construct()
    {
      parent::__construct();
      $this->load->library('whateveryouwant');
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
We're building an app, our first using Rails 3, and we're having to build
I have some data like this: 1 2 3 4 5 9 2 6
I have a text area in my form which accepts all possible characters from
this is what i have right now Drawing an RSS feed into the php,
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a bunch of posts stored in text files formatted in yaml/textile (from

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.