i’m starting to code in CI and i have some problems with the following matter: I need a controller that will return a list of databases from a given server-login-pass and the tables in each database.
Reading the user guide i’ve found everything i need, but still i have trouble managing to make this work. I believe i cant rely on the database.php config (multiple groups) since my controler has to accept any given server-login-pass.
Going straight to the point, i’ve tried this basic code and many variants without luck ;
$db1 = $this->load->database('mysql://flux:foo@localhost');
$db2 = $this->load->database('mysql://flux:foo@localhost/mydb');
$this->load->dbutil();
$db_list = $db1->list_databases();
print_r($db_list);
$db_tables = $db2->db->list_tables();
print_r($db_tables);
Also i'm not sure about:
$this->load->dbutil();
The user guide states:
Important: In order to initialize the Utility class, your database driver must
already be running, since the utilities class relies on it.
So if for example i had two simultaneous databases loaded, both with diferent drivers, how would i change $this->load->dbutil(); to load in the one id want?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…