Entity/PluginEnhancerCityStatePostalCodeRepository.php
public function updateReferenceTable(CityStatePostalCodeModel $model)
    {
        if (false !== ($fp = $model->fetchAllCountriesZip())) {
            $this->emptyReferenceTable();
            $this->createReferenceTable();
            $em        = $this->getEntityManager();
            $batchSize = 500;
            $count     = 0;
            while (!feof($fp)) {
                $data = explode("\t", trim(fgets($fp)));
                list(
                    $country,
                    $postalCode,
                    $city,
                    $stateProvince,
                    $state,
                    $county,
                    $a, $b, $c,
                    $latitude,
                    $longitude
                    ) = array_slice(
                    $data,
                    0,
                    11
                );
                if (!$country || !$postalCode) {
                    continue;
                }
                $record = new PluginEnhancerCityStatePostalCode();
                $record
                    ->setCountry($country)
                    ->setPostalCode($postalCode)
                    ->setCity($city)
                    ->setStateProvince($stateProvince)
                    ->setCounty($county)
                    ->setLatitude($latitude)
                    ->setLongitude($longitude);
                $em->persist($record);
                ++$count;
                if (0 === ($count % $batchSize)) {
                    $em->flush();
                    $em->clear();
                }
            }
            $em->flush();
            $em->clear();
        }
    }
public function updateReferenceTable(CityStatePostalCodeModel $model)
    {
        if (false !== ($fp = $model->fetchAllCountriesZip())) {
            $this->emptyReferenceTable();
            $this->createReferenceTable();
            $em        = $this->getEntityManager();
            $batchSize = 500;
            $count     = 0;
            while (!feof($fp)) {
                $data = explode("\t", trim(fgets($fp)));
                list(
                    $country,
                    $postalCode,
                    $city,
                    $stateProvince,
                    $state,
                    $county,
                    $a, $b, $c,
                    $latitude,
                    $longitude
                    ) = array_slice(
                    $data,
                    0,
                    11
                );
                if (!$country || !$postalCode) {
                    continue;
                }
                $record = new PluginEnhancerCityStatePostalCode();
                $record
                    ->setCountry($country)
                    ->setPostalCode($postalCode)
                    ->setCity($city)
                    ->setStateProvince($stateProvince)
                    ->setCounty($county)
                    ->setLatitude($latitude)
                    ->setLongitude($longitude);
                $em->persist($record);
                ++$count;
                if (0 === ($count % $batchSize)) {
                    $em->flush();
                    $em->clear();
                }
            }
            $em->flush();
            $em->clear();
        }
    }
public function updateReferenceTable ( CityStatePostalCodeModel $ model ) { if ( false !== ( $ fp = $ model -> fetchAllCountriesZip ( ) ) ) { $ this -> emptyReferenceTable ( ) ; $ this -> createReferenceTable ( ) ; $ em = $ this -> getEntityManager ( ) ; $ batchSize = 500 ; $ count = 0 ; while ( ! feof ( $ fp ) ) { $ data = explode ( "\t" , trim ( fgets ( $ fp ) ) ) ; list ( $ country , $ postalCode , $ city , $ stateProvince , $ state , $ county , $ a , $ b , $ c , $ latitude , $ longitude ) = array_slice ( $ data , 0 , 11 ) ; if ( ! $ country || ! $ postalCode ) { continue ; } $ record = new PluginEnhancerCityStatePostalCode ( ) ; $ record -> setCountry ( $ country ) -> setPostalCode ( $ postalCode ) -> setCity ( $ city ) -> setStateProvince ( $ stateProvince ) -> setCounty ( $ county ) -> setLatitude ( $ latitude ) -> setLongitude ( $ longitude ) ; $ em -> persist ( $ record ) ; ++ $ count ; if ( 0 === ( $ count % $ batchSize ) ) { $ em -> flush ( ) ; $ em -> clear ( ) ; } } $ em -> flush ( ) ; $ em -> clear ( ) ; } }
@param CityStatePostalCodeModel $model

@throws DBALException
@throws \Doctrine\ORM\OptimisticLockException
@param CityStatePostalCodeModel $model