Welcome Guest, Not a member yet? Register   Sign In
Connect to more than one database in a single connection
#1

(This post was last modified: 03-31-2024, 08:04 PM by mywebmanavgat.)

When you open a connection to a mssql database, you can jump to other databases if you have permissions.

Let's imagine that there are DATABASE_NAME_1 and DATABASE_NAME_2 databases.
For example, when you connect to DATABASE_NAME_1, the following query will jump to the other database.

PHP Code:
SELECT from DATABASE_NAME_2.dbo.tableName where id=


I have 3 databases on the same server. I am currently opening 3 different connections to these databases with codeigniter. This is very costly in terms of speed. What is the way to connect to one database with codeigniter and jump to other databases?


PHP Code:
$this->db->table('DATABASE_NAME_2.dbo.tableName')->select('*')->where('id',1)->get()->getResult(); 

Codeigniter outputs the following for this result.

PHP Code:
Select from DATABASE_NAME_1.dbo.DATABASE_NAME_2.dbo.tableName where id=



How can I provide usage with builder?
Reply


Messages In This Thread
Connect to more than one database in a single connection - by mywebmanavgat - 03-31-2024, 08:02 PM



Theme © iAndrew 2016 - Forum software by © MyBB