Zephius wrote:
Ok I think I got it this time! Tell me what you think. Come daily server reset it would run code that would rename all the backpacks in the database to a lower number and continue from the last one. That way I don't need to worry about an oversized variable (was my main concern). Unless I'm totally missing an easier way to do this. =/
Yes, if you really feel the urge to do keep the entries low, this would be the best way.
I would do it as such: (in php)
Code:
$sql = "SELECT * FROM `backpacks`";
$result = mysql_query($sql);
while( $row = mysql_fetch_array($result) ){
if( $row['used'] != 0 ){
$cleaned[] = $row;
};
};
// You'd drop the information alre(ady in the database by this point.
foreach( $cleaned as $key => $value){
foreach( $cleaned[$key] as $k => $v){
// in here all the inserting into the database would happen.
};
};
for
. . . blah blah
So, basically you take every entry in the database and cycle through it. If the variable "used" is set to 0 (mean it is no longer used) it is not written to the $cleaned array. Then, drop all the data in the table and finally you would take that array and put it into the database using new IDs.
Still, pretty pointless to do this anyway. You really won't see a huge difference unless your users will end up having 1,000,000,000,000s of backpacks. (That is, of course, if you are looping through every entry in the table to find which backpacks belong to each user; as opposed to having the user's backpack IDs stored in a file and just look up those IDs in the backpack table.) If your concern is about having more than an integers worth of IDs, then you could assign sub-IDs. Every 500, the next set will be given a sub ID 1 higher than before: ID[500], SubID[1] and then ID[1], SubID[2]. =P