Welcome Guest, Not a member yet? Register   Sign In
Dynamic DB Connection
#1

[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...?
#2

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

[eluser]Pygon[/eluser]
I believe this was discussed within the past week or so. You might use the search function.
#4

[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.
#5

[eluser]Pygon[/eluser]
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.
#6

[eluser]adamp1[/eluser]
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.
#7

[eluser]exodus7[/eluser]
The user guide shows you how to connect to the database manually like so:

Code:
$config['hostname'] = "localhost";
$config['username'] = "myusername";
$config['password'] = "mypassword";
$config['database'] = "mydatabase";
$config['dbdriver'] = "mysql";
$config['dbprefix'] = "";
$config['pconnect'] = FALSE;
$config['db_debug'] = TRUE;
$this->load->database($config);

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
#8

[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




Theme © iAndrew 2016 - Forum software by © MyBB