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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:54:36+00:00 2026-06-07T06:54:36+00:00

My Codeigniter system uses multiple databases. I don’t need every database on every page,

  • 0

My Codeigniter system uses multiple databases. I don’t need every database on every page, so I load each connection in the model where it’s needed, then load the required models within each controller. The profiler does not display any of the queries from these databases when I load things this way.

This is how I load the databases in my models:

$this->Companies_db = $this->load->database( 'companies', TRUE, TRUE );

I used to load all my databases in MY_Controller() ( an extension of the core controller ). When I load them there, the profiler works fine. When I load them in my models, it displays no database queries.

The database queries are being compiled in the method _compile_queries() within system/libraries/Profiler.php. When my databases are loaded in the model, their objects are not loading into the CI object. The code below is the first few lines from the _compile_queries() method and is where this is happening.

foreach (get_object_vars($this->CI) as $CI_object)
    {
        if (is_object($CI_object) && is_subclass_of(get_class($CI_object), 'CI_DB') )
        {
            $dbs[] = $CI_object;
        }
    }

How do I get the CI profiler to display my queries when I load my databases in my models? Or, more specifically, how do I get my database objects to load into the main CI object when the databases are loaded in the models.

  • 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-07T06:54:37+00:00Added an answer on June 7, 2026 at 6:54 am

    I would get an instance of the CI-object and store your database there, so that is also available to the profiler.

    class My_Model {
         private $Companies_db;
    
         public function __construct(){
               $this->Companies_db = $this->load->database( 'companies', TRUE, TRUE );
    
               // Pass reference of database to the CI-instance
               $CI =& get_instance();
               $CI->Companies_db =& $this->Companies_db;  
         }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am running multiple applications with a single Codeigniter system/ folder using the recommended
I have been using the CodeIgniter system for a while now - but it
I'm going to use Codeigniter's session data for my login system, but first I
I'm trying to integrate an adaptive payments system to my codeigniter project on my
CodeIgniter is brilliant but I'm using it to develop a site where users need
In codeigniter, I retrieve database results and store it in a variable like the
i m creating a login system in codeigniter. i m new in codeigniter. i
I'm writing a CRUD system using CodeIgniter, implementing some 'one to many' dependencies between
I have some problems with the email system for CodeIgniter: First, the emails I
Im currently using codeigniter to build a messaging system and im trying to stay

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.