PHP/MySQL question

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
csampson
Forum Newbie
Posts: 2
Joined: Sun Mar 06, 2005 6:51 am
Location: London

PHP/MySQL question

Post by csampson »

Hi,

I am working on an online soccer management game (kinda like championship manager) where the user can start a league, choose a team and play through seasons etc, and save their game so they can come back to it. Now I sort of have this working on the master DB, but I don't know how to go about making a copy of the DB for each user saved game as they create it.

Would there be any way of saving a copy of the DB to a file and then loading this when the user logs in to play and then saving back to file once they have finished? Either this or I guess I should be able to create a copy of the DB as another DB, but don't know how to go about this.

I hope this makes sense. If anyone could give me any pointers then that would be great.

Cheers,
Chris
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

Just to make my own questions clear.:wink:

First thing that comes to mind... Why be able to save at all? If the user leaves (ie. logs off, closes browser) the data itself is contained within the db.

Why do you need to store it a second time somewhere else?
csampson
Forum Newbie
Posts: 2
Joined: Sun Mar 06, 2005 6:51 am
Location: London

Post by csampson »

Sorry, didn't make my reasons clear.

Basically when a user starts a game they could get to, say, half way through the season and so the DB would have been updated with different player and team stats. If another person starts a game they will have to have a clean DB - so reset player and team stats etc (as each game would be independant of each other).

So really I think that they would have to have a new copy of the DB whenever a user starts a new game.

Thanks.
Chris
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

Ahhh... Yes, I should have realized this though.

My suggestion is to use a second table/db for this. It's more efficient compared to managing physical files (as *.csv, *.xml) code-wise. I think so that is. XML gurus might have other ideas.

13.1.4.1. INSERT ... SELECT Syntax might be of interest. Depending on what MySQL version you are running, there are multible ways of selecting data from one table and inserting it into another, with a simple query.

Support for an OUTPUT FILE is also mentioned if I still didn't convince you with my personal pref's about physical files... :wink:
Post Reply