Jump to content

[SOLVED] Start at 1 and end at 500, restart at 501 and stop at 1,000 ... possible?


monkeypaw201

Recommended Posts

I have the interesting challenge of updating 6,012 rows every 20 minutes :o :o if i try to run a script that large, i think the server would die.. so instead i would like to break it up into 5-10 different pages/crons that each run a little chunk of it..

 

Onto the problem, i know how to get it to stop at a certain number, but how do i tell it to start up at a number other than the beginning?

Depending on how your updating them, you can create loops like so:

 

for($i = 0; $i < 500; $i++){
//stuff
}

for($i = 500; $i < 1000; $i++){
// stuff again
}

 

or with the SQL LIMIT

 

"UPDATE tbl SET row = 'test' WHERE condition = "yes" LIMIT 0, 500"

"UPDATE tbl SET row = 'test' WHERE condition = "yes" LIMIT 500, 1000"

 

Yes, the SQL limit is what i was looking for, so the bold numbers are the start/stop numbers?

 

"UPDATE tbl SET row = 'test' WHERE condition = "yes" LIMIT 0, 500"

"UPDATE tbl SET row = 'test' WHERE condition = "yes" LIMIT 500, 1000"

Yes, the SQL limit is what i was looking for, so the bold numbers are the start/stop numbers?

 

"UPDATE tbl SET row = 'test' WHERE condition = "yes" LIMIT [b]0[/b], [b]500[/b]"
"UPDATE tbl SET row = 'test' WHERE condition = "yes" LIMIT [b]500[/b], [b]1000"[/b]

 

Nope.  Do it like this:

UPDATE tbl SET row='test' WHERE condition ="yes" LIMIT 0, 500;

UPDATE tbl SET row='test' WHERE condition ="yes" LIMIT 500, 500;

UPDATE tbl SET row='test' WHERE condition ="yes" LIMIT 1000, 500;

UPDATE tbl SET row='test' WHERE condition ="yes" LIMIT 1500, 500;

 

Now do that in a script.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.