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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:15:54+00:00 2026-05-26T11:15:54+00:00

I have a multi-tenancy application that I am developing and I’m nearly there. Currently

  • 0

I have a multi-tenancy application that I am developing and I’m nearly there.

Currently I am using one database per customer – copying it each time and naming depending based on $_SERVER[‘http_host’]…

A lot of the tables each database never change, and contain the same information.

I would like to have a main application database that contains this information, including a list of clients and what there database is called. This database would then be used to select the correct customers database…

Is this possible and can anyone point me in the direction of a suitable tutorial?

Thanks

  • 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-26T11:15:54+00:00Added an answer on May 26, 2026 at 11:15 am

    OK, so you’ll need different database configs for your “administrative” database and your “customer” databases.

    Use the examples from this page to generate those separate configs:

    http://ellislab.com/codeigniter/user_guide/database/configuration.html

    Then, in your main controller (please tell me your extending a MY_Controller.php and not just using CI_Controller.php), you’ll want to read your ‘admin’ database and get all client information. You’ll then want to generate a $config array for this client database and reload the database with the new $config array:

    // in MY_Controller constructor
    
    // do your thing here to connect to the admin database and get client details
    // ...
    //
    
    $config['hostname'] = "localhost";
    $config['username'] = $client_db_username; // you got this from the 'admin' database
    $config['password'] = $client_db_password; // you got this from the 'admin' database
    $config['database'] = $client_db_name; // you got this from the 'admin' database
    $config['dbdriver'] = "mysql";
    $config['dbprefix'] = "";
    $config['pconnect'] = FALSE;
    $config['db_debug'] = TRUE;
    $config['cache_on'] = FALSE;
    $config['cachedir'] = "";
    $config['char_set'] = "utf8";
    $config['dbcollat'] = "utf8_general_ci";
    
    $this->load->database($config);
    

    You’ll then have a connection to the client database.

    Note
    If you’ll need to connect to both databases back and forth, then you can connect to multiple databases as explained on this page: http://ellislab.com/codeigniter/user_guide/database/connecting.html

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

Sidebar

Related Questions

HI There, i have to make my application SAAS compliant .For achieving multi tenancy
I'm working on one multi-tenancy application, where each tenant will have access to 1
I have a multi-timezone web application that stores all of the datetime values in
I have a multi-threaded Windows application that occasionally deadlocks. Inevitably this happens on a
I'm currently working on a SaaS type application, and for multi-tenancy I've settled on
I have multi-thread application that I want to create a thread with different user
I want to convert my application to support multi-tenancy using shared tables (i.e. every
I have an app that uses subdomains to switch databases (multi-tenancy). I'm trying to
I'm designing a database for pure multi-tenancy (one database, one schema) and I'd like
Modern browsers have multi-tab interface, but JavaScript function window.showModalDialog() creates a modal dialog that

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.