Jump to content

Recommended Posts

Just want to get peoples opinions on the recommended way to go about this.

 

I am attempting to build a guild management tool using php. (for wow in case your curious) and I want to store the classes, races, and any other static data for use in lists, and other functions.

 

I was thinking of just setting up a static table for classes, but I think that might be a waste of resources.

The other way would be to store them all in a static array in a config file.

 

What is the best practice route to take on something like this.

 

I am leaning more towards the config file.

Link to comment
https://forums.phpfreaks.com/topic/219392-database-vs-config-file/
Share on other sites

Everything depends on how you want to use the data. Most certainly you want to avoid people specify invalid class names so your database should be something like:

 

CREATE TABLE Classes (
  class_id VARCHAR(32) NOT NULL, -- class name
  PRIMARY KEY (class_id)
) ENGINE=INNODB;

CREATE TABLE Characters (
  character_id VARCHAR(32) NOT NULL, -- character name
  class_id VARCHAR(32) NOT NULL,
  ..
  PRIMARY KEY (character_id),
  FOREIGN KEY (class_id) REFERENCES Classes (class_id)
    ON UPDATE CASCADE
) ENGINE=INNODB;

 

If you are playing against a specific version then you could use:

 

CREATE TABLE Characters (
  character_id VARCHAR(32) NOT NULL, -- character name
  class_id ENUM('<class-id-1>','<class-id-2>') NOT NULL,
  ..
  PRIMARY KEY (character_id)
) ENGINE=INNODB;

 

This makes it easy to manage it from a back-end. The first example will allow you to easily also add classes the second one doesn't and will make it costly to do so. I do not recommend using a config file instead you could use:

 

class RaceClass {
    private $validClasses = array(
        ..
    );
}

Thanks for the advice ,

 

I am thinking the class might be the best route for this since those have only changed once in the 5 years wow has been out (they added death knights).

Not only that but I won't be allowing users to type in their class, they will only be able to select from a pre-compiled list (drop-down).

 

Thanks man, your input is always helpful.

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.