Devam Ediyor

505721 php script to _guess_ number of records

There is an API that I'm integrating with and one of the weaknesses of it is that you can't get a results count from a single query -- it only returns 1000 results at a time, so you have to keep running the query, returning the next set of results until you get a set that is less than 1000 (so you know you've reached the limit).

I need a php script that can help determine how many results there are in the least amount of queries.

So for example, say there are 585,783 records (but I don't know that to start with)

I will give the script a starting number like 500.

I will run my query to see how many results there are for page 500. If there are 1000 result (the max), then I know that it's on a higher page, so the script should double that to 1000. I check page 1000 and see there are no results, so I know that is too high. So the script now needs to return the midpoint between 500 and 1000 ... so I check to see if there are results for page 750. No result? Then I need the midpoint between 500 and 750 ... and so on until I find a midpoint number the returns results greater than 0 but less than 1000.

This way rather than having to run the API script 585 times, I run it through only 8 times (in this example)

try 500 = greater

try 1000 (500 * 2) = less

try 750 (midpoint btwn 500 and 1000) = less

try 625 (midpoint btwn 500 and 750) = less

try 563 (midpoint, rounded, btwn 500 and 625) = more

try 594 (midpoint, rounded, btwn 563 and 625) = less

try 579 (you get the point) = more

try 585 (BINGO ... results for this page are 783 ... greater than zero, less than 1000)

So I'll provide the starting number and the number of results from that query, then this script needs to provide me with a new number to try. I would like to be able to use this within a 'while' statment so my query repeats until it finds the result.

Beceriler: Her şey Kabul, PHP, Kabuk Betiği

Daha fazlasını görün: weaknesses, run shell script from php, help with php script, example of weaknesses, api 750, 3 weaknesses, example shell script, set of s, need help php script, double api, php statment, result number, script bingo, need run can provide script run, result double, script number guess, number count, php single query, count number, script bingo php, php rounded, bingo script php, script limit, php script api, php script bingo

İşveren Hakkında:
( 104 değerlendirme ) Mebane, United States

Proje NO: #2251646



Details in PM.

1 gün içinde 40$ USD
(53 Değerlendirme)