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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T21:02:21+00:00 2026-06-01T21:02:21+00:00

i need to connect for many databases the primary connection in the database.php and

  • 0

i need to connect for many databases
the primary connection in the database.php
and there is no problem with that

but the another connections must be in Model

i use this class

<?php
class user_model extends CI_Model {

        public function test()
        {
        $specific['hostname'] = "localhost";
        $specific['username'] = "root";
        $specific['password'] = "";
        $specific['database'] = "ci_forsyria";
        $specific['dbdriver'] = "mysql";
        $specific['dbprefix'] = "";
        $specific['pconnect'] = FALSE;
        $specific['db_debug'] = TRUE;
        $specific['cache_on'] = FALSE;
        $specific['cachedir'] = "";
        $specific['char_set'] = "utf8";
        $specific['dbcollat'] = "utf8_general_ci";

        $this->load->database($specific);

        //get data using datamapper
        $o = new db_user();
        $array = array();
        $o->where($array)->get();
        echo $num_rows = $o->result_count();
        }
}
?>

but the connection is not work
it’s still connect with the primary database

Error Number: 1146
Table ‘countries.ci_users’ doesn’t exist

Note: i don’t wont to but the another connections in the database.php file because i have more than 100 connections

  • 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-01T21:02:22+00:00Added an answer on June 1, 2026 at 9:02 pm

    In reaction to your comment to Repox, you most certainly must be using it wrong. His last solution must work, I use it myself continuously. Can you show what “new db_user()” is for an object, you might use the general database?

    Note: leave the closing tag here, it’s a model:

    For files that contain only PHP code, the closing tag (“?>”) is never
    permitted. It is not required by PHP, and omitting it´ prevents the
    accidental injection of trailing white space into the response.

    Try this for an example, it should return 30 values from the countries table.

    <?php
    class user_model extends CI_Model {
        public function test()
        {
        $specific['hostname'] = "localhost";
        $specific['username'] = "root";
        $specific['password'] = "";
        $specific['database'] = "ci_forsyria";
        $specific['dbdriver'] = "mysql";
        $specific['dbprefix'] = "";
        $specific['pconnect'] = FALSE;
        $specific['db_debug'] = TRUE;
        $specific['cache_on'] = FALSE;
        $specific['cachedir'] = "";
        $specific['char_set'] = "utf8";
        $specific['dbcollat'] = "utf8_general_ci";
    
        $specific_db = $this->load->database($specific, TRUE);
    
        $example_query = $specific_db->query('SELECT * FROM countries LIMIT 0,30')->result();
    
        return var_dump($example_query);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Many database libraries come setup for multiple database connections - but I've never actually
I need to connect Apache Axis 1.4 to a Webservice that uses NTLM authentication
I need to connect my php script to Gmail Atom feed to retrieve the
i need to connect to another server we manage and have it's results (in
I need to connect to SAP and do a simple update but it will
I need to connect to a SQL Server 2008 through PHP (WAMP, latest version).
I need to connect the Symbian OS device and communicate with files. Is there
I have a PHP script that reads and writes from multiple databases. I am
I need to connect a SQL Server 2008 database to an asp.net website project.
We have a large Oracle database with many tables. Is there a way I

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.