![]() |
PHP Code: $this->db = \Config\Database::connect('default'); The Code above works Properly, but you cannot switch to another database with Builder because builder always adds the database of the active connection itself at the beginning of the table name. Update Post 2: This is the result when you try to do it with buider. PHP Code: $builderForDb2 = $this->db->table('LOG_DB.dbo.adminLogs',false,false,false); Update Post : 3 The code below works, but if you use left join etc. features to tables in different databases in the builder, you will encounter problems again.also every time you change the database name you have to change it back, or you have to set the database name before each query. PHP Code: $this->db->setDatabase('LOG_DB'); |
Messages In This Thread |
Connect to more than one database in a single connection - by mywebmanavgat - 03-31-2024, 08:02 PM
RE: Connect to more than one database in a single connection - by kenjis - 03-31-2024, 09:11 PM
RE: Connect to more than one database in a single connection - by kenjis - 04-01-2024, 01:48 AM
RE: Connect to more than one database in a single connection - by mywebmanavgat - 04-01-2024, 06:38 AM
RE: Connect to more than one database in a single connection - by mywebmanavgat - 04-01-2024, 07:39 AM
RE: Connect to more than one database in a single connection - by mywebmanavgat - 04-01-2024, 10:08 AM
RE: Connect to more than one database in a single connection - by kenjis - 04-01-2024, 09:19 PM
|