Big Foreach Loop with Google Maps API

i have a bigger issue with a foreach() Loop and the Google Maps API class.

Currently i have 1500 datasets in my MySQL Table, i sort them out by “latitude IS NULL”.
Then i want to foreach() them and call the Google Maps API (KM6_Geo) each time and Save the new geocodes to the MySQL Database.

BUT:
After about 250/300 Calls / Updates my Server replies with an “timeout”.

Now this is my current script:

    foreach(KM6_Addresses::getGeoCodes() as $item):

        $geocode = KM6_Geo::generate($item['street'].' '.$item['zipcode'].' '.$item['city']);
        $data = array(
            'lat'       => $geocode['lat'],
            'lng'       => $geocode['lon']

        );

        $where = array('company_id' => $item['company_id']);        
        KM6_Addresses::updateGeoCode($data,$where);
    endforeach;

Now my Question:
How can i foreach() with packages or something like that. So i do not try to update 1500 data sets.

Maybe someone can help me out.

Thanks! ;)

Leave a Reply

*

Hire Me
Follow Me!
Search
Most Popular Articles & Pages
Because your vote is Important
Sorry, there are no polls available at the moment.
Categories