I have a table on my db called 'user_accounts' which stores each members info. I also have a db table called 'games' which stores data for different games on the server. Each game is identified by a 'db_name' which is stored in the 'games' table. the 'db_name' also acts as a prefix for other tables on the db specific to that game, for example 'db_name'_users. Im currently working on an Admin removal script. I can quite happily remove the Admin from the main user_accounts table. However, I need to find if that user is currently in any games, and if so delete them from the game aswell.
The main issue is because db_name is dynamic, and the script will be generic. Its part of an install utility, so the code needs to work for whatever the end user sets the db_name to.
What im trying to achieve is this:
a sql query on the 'games' table, which will give me all the 'db_name' values, and then search each 'db_name_users' table for the user. if the user is pressent then delete all entries of that user from that game. The user can be in multiple games, so it would have to delete them from all the games they are in.
I can normally figure things out via trial and error, but this is really causing me headaches, any ideas that someone can chuck at me 2 try out?