0

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?

3
  • have you tried $db1->load->dbutil(); ? Commented Oct 23, 2011 at 17:03
  • Found detailed help in: codeigniter.com/forums/viewthread/202659 Commented Oct 24, 2011 at 21:01
  • yep, mark your question as answered please Commented Oct 25, 2011 at 10:00

1 Answer 1

1

Found detailed help in: www.codeigniter.com/forums/viewthread/202659

Sign up to request clarification or add additional context in comments.

1 Comment

I can't see your link. can you show me the right link? thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.