user160108
user160108

Reputation: 920

codeigniter single application multiple databases

I will be shifting my code base to the new 2.0 framework and just had a few questions on the following points

My urls will be as follows

I would like to know what would be the best way to switch the database based on the city in the url? .

In my webroot i will have directories like city1, city2 each containing an index.php file which points to the single code base.

Now i only need a way to switch the database based on the url entered.

Regards, Sheldon

Upvotes: 0

Views: 413

Answers (1)

BigFatBaby
BigFatBaby

Reputation: 1510

I completely agree with @poelinca and @Ross, you should definitely consider rethinking your design.

however for reference issues this topic was already covered in the CodeIgniter forums pretty well over here

Basically you just configure another set of $db items per connection and then request the connection based on those configuration parameters by the CodeIgniter framework, by providing the new $db as a parameter for the DB class constructor.

Upvotes: 1

Related Questions