doctrine2 - symfony batch only first flush is working -


in code below. first flush() working. subsequent flushes being reached , called, having no effect.

if remove flush() , clear() loop, records updated (but need limit search prevent memory issues).

$processedentries = 0;  $advertquery = $entitymanager->createquery(     "select        mybundle:advert        left join mybundle:history prh       prh.id null" );  $advertquery->setfirstresult(0); $advertresults = $advertquery->getresult();  foreach ($advertresults $advertentity) {     $advertentity->settimemodified(new \datetime());      try {         $processedentries++;          if (($processedentries % self::commit_batch_size) === 0) {             $entitymanager->flush(); // executes updates.             $entitymanager->clear(); // detaches objects doctrine!         }      } catch(\exception $ex) {          $this->getcontainer()->get('doctrine')->resetentitymanager();         echo $ex->getmessage();     } }  $entitymanager->flush(); // executes updates. 


Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

mapreduce - Resource manager does not transit to active state from standby -

serialization - Convert Any type in scala to Array[Byte] and back -