SA-MP Forums Archive
Question regarding SQL data load + loops - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Question regarding SQL data load + loops (/showthread.php?tid=288588)



Question regarding SQL data load + loops - Derryd - 08.10.2011

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.


Re: Question regarding SQL data load + loops - Derryd - 08.10.2011

Quote:
Originally Posted by ******
Посмотреть сообщение
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.


Re: Question regarding SQL data load + loops - Derryd - 08.10.2011

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