PDA

View Full Version : Question regarding SQL data load + loops


Derryd
08/10/2011, 11:35 AM
I'm loading my vehicles from my MySQL database, however, I'm allowing for players to delete their vehicles in-game and thus obviously a 'DELETE FROM' is called. This causes the id's of the cars on the DB to break out of order (Example: 213, 215, 216)

When the function is called to load the data it gets to the car ID which doesn't exist and creates X amount of cars from the last vehicle loaded. X is equal to the range of missing id's. How do I make it so the loop detects 0 rows returned for the 'SELECT * FROM vehicles WHERE id = X' and stops the load of data for that car, but still continues?

Thanks.

Derryd
08/10/2011, 11:44 AM
Why are you looping in the first place? What's wrong with just loading all vehicles in a single query and looping through the results?
I guess I've just always done it this way on everything I code.

Derryd
08/10/2011, 11:47 AM
Anyway, for my issue, I'm guessing I have to check the row count for that specific loop and then cause the loop to skip loading for that specific car, and continue to the next ID.

How do I do that? lol