Loop < || > ?

Solved, thank you all.

What? O_o

The closest I understand is this:
PHP код:
rows || rows 
But that doesn't make any sense at all and it would still stop the loop when r == rows.

Just use
pawn Код:
for(new r = UlIDV; r != cache_num_rows(); ++r)
In case "r < || > cache_num_rows()" means that r can be smaller or bigger than cache_num_rows, but not equal to it.

!= does the same thing in that scenario, because when a number isn't equal, it will automatically be smaller or bigger than the other number.

As Vince said, it has no use inside a loop which only runs in one direction, in this case upwards.

If your variable "UlIDV" (example: 10) would already be bigger than cache_num_rows (example: 7), your loop would run about 4 billion times.
"r" will start at 10, then count upwards until you reach the 32-bit binary limit: about 2.1 billion.
Then it will roll-over to negative (about -2.1 billion) and start counting upwards towards 0, roll-over that too until it reaches 7. Then your loop will end.

Your server will have enormous lag and if you're not careful, your OS will think the server has crashed because it doesn't respond anymore and will be terminated.

Your variable should always be lower than the amount of rows in your database, thus you have no use for the "smaller or higher" operator.
Also: when you create queries and don't plan to start reading them from the beginning (row 0), you should re-define your query to hold the results you need without the need to skip some rows using that variable.
"r" should always start at row 0 (or if you want to read the result backwards, set it to cache_num_rows-1) and run your loop downwards.

If you mean Less Than or Greater Than Operator (something like <>) Then it's not made
you can use

Thank you all!

Once again, Do NOT remove / edit your thread, as other people can check your thread on how to fix the same problem when they are facing it.

Forum Jump:

Users browsing this thread: 1 Guest(s)