Choosing CodeIgniter

#1
[eluser]happyeddie[/eluser]
I'm looking into using CodeIgniter for a large project I'm about to start. The two main parts of the system are:

A) The ability to choose a database depending on the user - So instead of declaring a database in config, save the database name in a session and use the data in the session to load a particular database. To make it a bit more clear, say I have 4 database's each with the same schema, so database red, yellow, blue, green. And when the user logs in a session is saved saying that this user uses database 'red'.
And in the model I can then say load database 'red'.

B) Multilingual - Is there an easy way, and if possible, to have different views with different languages (english, french, german) and have the controller and model use the one script for each language (reducing duplication). Would the best way to do this as follow:?

Views:
(en)
(fr)
(de)
So basically I want to have multilingual support but not have to replicate all the code.

Is all this relatively easy to do with codeigniter? or any design ideas you can recommend in achieving the above solutions.

Many thanks.

#2
[eluser]AgentPhoenix[/eluser]
[quote author="happyeddie" date="1258151350"]A) The ability to choose a database depending on the user - So instead of declaring a database in config, save the database name in a session and use the data in the session to load a particular database. To make it a bit more clear, say I have 4 database's each with the same schema, so database red, yellow, blue, green. And when the user logs in a session is saved saying that this user uses database 'red'.
And in the model I can then say load database 'red'.[/quote]

Yeah, you can certainly do that. I think the best thing to do would be to create database connection arrays (in config/database.php) for each of the databases then you can connect to the database in the constructor by just calling the proper database config array. Just make sure you do a check for the existence of a session otherwise you'll probably be spitting out some error. You might want to do something like:

Code:
if ($this->session->userdata('userid') !== FALSE)
{
    $this->load->database($this->session->userdata('database'));
}

Of course you'll want to expand that to make sure you're sanitizing the data that's coming in from the session, just to be safe. You can read a lot more information about the database connections here.

[quote author="happyeddie" date="1258151350"]B) Multilingual - Is there an easy way, and if possible, to have different views with different languages (english, french, german) and have the controller and model use the one script for each language (reducing duplication). Would the best way to do this as follow:?

Views:
(en)
(fr)
(de)
So basically I want to have multilingual support but not have to replicate all the code.[/quote]

This is very possible and there are a lot of CI sites that do this. One thing you might want to look at is the URI Language Identifier. That might be a good place to start when trying to work out the best way to structure your app in the event you'll have several different languages.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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