Tacomon
05-17-2006, 05:24 AM
Let's say I'm making an online game where players are able to collect items. Thousands of these items will be available and their attributes will be static. At first, I had the items in a database, where I skipped id numbers to separate the type of items (I did this by 1000s so I'd have room to add more). The setup looked something like this:
id | item
1 gun1
2 gun2
...
1001 laser1
1002 laser2
...
2001 missile1
2002 missile2
and so on
After thinking about the setup, I moved them out of a database (database should be for dynamic data) and into one big array , which is in an include file.
Now I've got a huge array of thousands of items that I'm including in most of my php files and I'm worried about file size implications and performance.
What would be the best way to deal with a scenario like this where one has thousands of static entries broken down into categories?
- Go back to the database?
- Put everything in a big array?
- Make separate arrays for each item type (1000/array)?
- Some other method?
Thanks!
id | item
1 gun1
2 gun2
...
1001 laser1
1002 laser2
...
2001 missile1
2002 missile2
and so on
After thinking about the setup, I moved them out of a database (database should be for dynamic data) and into one big array , which is in an include file.
Now I've got a huge array of thousands of items that I'm including in most of my php files and I'm worried about file size implications and performance.
What would be the best way to deal with a scenario like this where one has thousands of static entries broken down into categories?
- Go back to the database?
- Put everything in a big array?
- Make separate arrays for each item type (1000/array)?
- Some other method?
Thanks!