SaigonJeff
asked on
Switching Database Connections
Hello to all experts
I have a very perplexing problem and would like to know if what I am trying to do is possible in PHP.
Scenario:
I have designed a website for a local Golf and Country Club and the client have requested the site to be made available in 5 different languages. Normally I would do it the old-school way and build a complete duplicate site in a separate directory using the second language and link between them but with 5 foreign languages, this would be a colossal effort.
So what I want to achieve is to duplicate the databases in each of the languages and then load the appropriate language that the user selects from a list.
This means that I need to be able to select the language by using one of 5 connection scripts and have all page in the site use the same connection script until another language is chosen and then all the pages use the new connections script.
I just can't seem to figure out how to accomplish this and I'm beginning to wonder if can even be done in PHP. Can anyone out there confirm if this can be done?
Please see the attach flowchart to see what I mean.
Thanks to all.
multilingual-flowchart.pdf
I have a very perplexing problem and would like to know if what I am trying to do is possible in PHP.
Scenario:
I have designed a website for a local Golf and Country Club and the client have requested the site to be made available in 5 different languages. Normally I would do it the old-school way and build a complete duplicate site in a separate directory using the second language and link between them but with 5 foreign languages, this would be a colossal effort.
So what I want to achieve is to duplicate the databases in each of the languages and then load the appropriate language that the user selects from a list.
This means that I need to be able to select the language by using one of 5 connection scripts and have all page in the site use the same connection script until another language is chosen and then all the pages use the new connections script.
I just can't seem to figure out how to accomplish this and I'm beginning to wonder if can even be done in PHP. Can anyone out there confirm if this can be done?
Please see the attach flowchart to see what I mean.
Thanks to all.
multilingual-flowchart.pdf
ASKER
That would be easier, but the database is also feeding 5 different sites. The tables from on site are exactly duplicated for each other site and I use a prefix to distinguish the tables for each one. Adding a suffix might work better I think.
SELECT * FROM $_SESSION['table']_['lang' ]
SELECT * FROM $_SESSION['table']_['lang'
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for your help... I do believe you have given me the answer I was looking for.
I will give it a try and post my results.
In the meantime, I will accept this as a viable solution.
I always learn something here on EE.
I will give it a try and post my results.
In the meantime, I will accept this as a viable solution.
I always learn something here on EE.
Wouldn't it be easier to have one database (and one connection script) and just have multiple tables for the different languages?
So all you would need to do is have the user set the preference and then call the correct set of tables. Name the tables with the language prefix (e.g. jap_content, eng_content) and then alter any calls to a table to put the prefix in dynamically:
SELECT * FROM $_SESSION['lang']_content