Jump to content
Larry Ullman's Book Forums

Two Database Connections


Recommended Posts

Hello everybody,

I’ve studied this book and ask a few questions a couple of month ago, in the other forum.

The book proved very useful and the php I’m writing improved immensely.

However I’m building now my own site and I would like to be able to shift between two languages: Spanish and English.

I’m thinking about using 2 database connections but I’m not very sure how to do it. (in the public zone, and in the staff zone)

Can you give me a general idea?

In a couple of days or so I will receive your MySQL second edition, where from I’m hoping to get some more ideas.

Thank you in advance for your help.

Link to comment
Share on other sites

Thanks for the nice words on the book. Sometimes you can create two database connections by assigning them to two different variables. However, database connections are expensive, in terms of server resources, so I'd recommend finding a different way. For example, you can use one connection but switch databases as needed.

Link to comment
Share on other sites

Going off the assumption that you will be inputting the two different languages and not just translating the page text

maybe something like this would work.

 

1 database set up like this

 

[table] lang

-- id

-- name

 

[table] page

-- id

 

[table] page_lang

-- id

-- page_id

-- language_id

-- title

-- content

 

Then you have the user select their language and assign that ID to a session so it pulls the correct language title and content for the page.

 

Seems like it would be the easiest to maintain and expand if you need to add another language.

Just a thought.

  • Upvote 2
Link to comment
Share on other sites

 Share

×
×
  • Create New...