Welcome Guest, Not a member yet? Register   Sign In
switching between 20 database
#1

[eluser]Unknown[/eluser]
hi,
i have 20 websites with the same database structures ,each one has his own back-end and it take lot of time to do some changes becuase i have to loggin to each one to work on.

to resolve this problem , i took one of my back-ends i tried to do some changes on it to work for all my websites.

first i created a database for this project with a ‘user’ table for the logging process, then in my administration interface i added a dropdown menu to select witch website/database i’d like to work on.

the problem is how can i swtich between my 20 databases (this number can change) without changing my models/controllers , because i have too many many files (models/controllers).


i’m using CI V1.7.2

thanks.
#2

[eluser]jmadsen[/eluser]
http://ellislab.com/codeigniter/user-gui...cting.html
#3

[eluser]Unknown[/eluser]
i looked there before i post.

i have to mention that in config/database.php file i just added the params to connect to the logging database, and the others 20 database params are stored on my session after the logging prosess ,

so when i select a website to work on it i have to close the default connection and open a new one with selected website params.
#4

[eluser]Aditzu[/eluser]
[quote author="nooneelse" date="1352121390"]i looked there before i post.

i have to mention that in config/database.php file i just added the params to connect to the logging database, and the others 20 database params are stored on my session after the logging prosess ,

so when i select a website to work on it i have to close the default connection and open a new one with selected website params.[/quote]


You can simply set your logging database as your default database and for the other databases just set like this:
Code:
$DB1 = $this->load->database('site1', TRUE);
$DB2 = $this->load->database('site2', TRUE);
...
Code:
$DB20 = $this->load->database('site20', TRUE);
and to access databases use
Code:
$this->db->query();
$this->db->result();
for the default databse

and
Code:
$DB1->query();
$DB1->result();
...
for the rest of if




Theme © iAndrew 2016 - Forum software by © MyBB