Answer the question
In order to leave comments, you need to log in
Codeigniter: How to get $db array from config/database.php in model?
The config/database.php file contains the $db array with connection options.
How to get this array from the model?
What for? It is necessary to pull out names of databases for simultaneous use in one request.
Example:
select t1.name from db1.table1 t1 left join db2.table1 t2 on (t1.id = t2.t1_id)
$this->db->database
Answer the question
In order to leave comments, you need to log in
I did not find anything smarter and simpler than this option:
public function __construct()
{
include APPPATH . 'config/' . ENVIRONMENT . '/database.php';
$this->db_config = $db;
....
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question