• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CI4 .env file connecting to multiple databases not working

#4
I've had a similar problem where I was able to define connection to the second database, but the convenience model methods (such as $theModel->findAll() ) not working on models based on the 2nd database.

Consider:


Code:
$modelBasedOnDb1 = model('model1'); // using $db1
$results1 = $modelBasedOnDb1->findAll(); // works fine

$modelBasedOnDb2 = new ModelBasedOnDb2();
$modelBasedOnDb2->db = $db2; // despite this
$results2 = $modelBasedOnDb2->findAll(); // produces some error like: no such table (whatevertable) on"DB 1"


(I used pseudo-names to describe the problem)

I ended up merging 3 databases in a single database because of this problem.
(Happened with CI 4.0.4 - I haven't tried again with CI 4.1.x)

CodeIgniter Wizard (CRUD code generator for Mac) instantly scaffolds Bootstrap-based web applications with an administrative interface.

Reply


Messages In This Thread
RE: CI4 .env file connecting to multiple databases not working - by gosocial2 - 02-02-2021, 08:59 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.