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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:13:25+00:00 2026-05-27T23:13:25+00:00

In my autoload file I have several common libraries and several common model autoloaded:

  • 0

In my autoload file I have several common libraries and several common model autoloaded:

$autoload['libraries'] = array('database','session','tools','common'....);
$autoload['model'] = array('mauth','madmin',...);

I’m in calling this code inside a library that calls another library:

class library1{
  function x(){
    $this->CI =& get_instance();
    $this->CI->library2->y();
  }
}

class library2()
  function y(){
    $this->CI =& get_instance();
    $array_notifications = $this->CI->madmin->getNotifications();
  }
}

And I get:

Message: Undefined property: Splash::$madmin

I guess I may do this:

$this->CI->load->model('madmin');

But.. why? Why Can’t I decide the load priority of my autoloaded classes?

Thanks

EDIT: Clarification

  • 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-27T23:13:26+00:00Added an answer on May 27, 2026 at 11:13 pm

    AFAIK there’s no possibility of choosing the loading priority, and I think that hacking the core just to avoid writing a line is a bit…off.

    I had to go search the core system to see better how things work. Looks like libraries are autoloaded before models, so you are right when saying that you need to load the model before calling one of its methods (I didn’t tested though, but I think it works like this).

    I don’t know why is this done, but so far the only solution I see is to change yourself the order in which are loaded, but I warn you: I think that if things work this way there’s a reason the CI developers has thought about; this might have drawbacks you cannot tell, so always be ready to a drawback in case you find problems.
    This solution is just a bit speculative and not guaranteed, I’ll appreciate your feedback as I cannot set up a testing environment right now to prove it

    Go to the system/core/loader.php file, around line 1166 (the method is _ci_autoloader()) where the “libraries” index of $autoload array is checked, and swap its position with the ‘model’ index checking which is around line 1183.

    And good luck 🙂

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

Sidebar

Related Questions

I have several small classes that are in a single file in /app/models, similar
I have a combination of: autoload -Uz compinit compinit and autoload -Uz vcs_info It
I'm using PHP Doctrine and i've setup autoloading: spl_autoload_register(array('Doctrine', 'autoload')); spl_autoload_register(array('Doctrine', 'modelsAutoload')); I can
I am using $data in all my views $this->load->view('my_view', $data); I have also autoload
I have a script that uses autoload to load classes that aren't found. I
i have a .js file where i show a list of pools. And when
I would like to autoload a local javascript file, everytime a new page/tab is
I am new in Sencha i have created var genres = new Ext.data.Store({ autoLoad:
Here is the exact problem. I have an autoload function set up with a
I have several classes that need to load some properties files, and I was

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.