• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dynamic DB Connection

[eluser]Matthew Lanham[/eluser]
Hi Guys,

The application i am building with use a seperate database for each client for additional security, however i need to be able to load a dynamic config for the database to CI and have that available throughout the application session..

Just wondered how i can achieve this...?

[eluser]Matthew Lanham[/eluser]
Still need some help Confused

I believe this was discussed within the past week or so. You might use the search function.

[eluser]Matthew Lanham[/eluser]
I have used the search function but i cannot find anything that talks about what i am trying to achieve, there is discussion about having a couple of connections, but i could be talking over 500 databases, so i need a simple way to choose the database to connect to on login to the system based on part of the login process.

TBA: I'm not sure why you would consider 500 databases a good solution by any means, but a search for "multiple database" yields quite a few results on this topic.

500 Yikes! Woooo I wouldn't want to think of the overheads. Why not have tables and instead only grant user access to specific tables? That way you use the same DB, problem is then dynamic database user switching.

The user guide shows you how to connect to the database manually like so:

$config['hostname'] = "localhost";
$config['username'] = "myusername";
$config['password'] = "mypassword";
$config['database'] = "mydatabase";
$config['dbdriver'] = "mysql";
$config['dbprefix'] = "";
$config['pconnect'] = FALSE;
$config['db_debug'] = TRUE;

you can set your variables to = what's in your session like so: $config['hostname'] = $this->session->userdata('item');

Read more about it at: http://ellislab.com/codeigniter/user-gui...cting.html

I'm no expert but If your looking to keep your clients db secure, I would suggest a different alternative than creating multiple databases - its a waste of time, $$$, and resources in my opinion.

Good luck in your project

[eluser]Matthew Lanham[/eluser]
I have managed to kind of figure out a solution although im in need of a function that tests in the database exists, but nearly there...

I did think about a prefix on tables, but i guessed it would be easier to manage to have them in separate databases, my initial thought was to just have a CODE assigned to each row in the tables i need, but i feel there is room for data leaks in this....plus trying to manage the data could become difficult

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

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