Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.03 KB | None | 0 0
  1.  
  2. With the foreach commented out, the code runs without errors.
  3.  
  4. If this line is uncommented:
  5.  
  6.            foreach ($sale->getInvoices() as $invoice) { }
  7.  
  8. Then the code breaks with this error.
  9.  
  10. Notice: Undefined index: 00000000583b34730000000060d36b73 in .../
  11. vendor/doctrine/lib/Doctrine/ORM/UnitOfWork.php on line 2053
  12.  
  13. = = = = = = = = = = = = = = = = =
  14.  
  15. public function indexAction() 
   
  16. { 
       
  17.         $em = $this->get('doctrine.orm.entity_manager');
  18.      
  19.         $q = $em->createQuery("select s from CoreBundle:Sale s"); 
         
  20.         $results = $q->getResult(); 
       
  21.    
  22.     $count = 0; 
       
  23.     foreach ($results as $sale) { 
           
  24.         $sale->setValue(rand());
  25.            
  26.         // FOREACH COMMENTED OUT 
       
  27.         // foreach ($sale->getInvoices() as $invoice) { }
  28.            
  29.         if (0 == $count++%50) { 
               
  30.             $em->flush(); 
               
  31.             $em->clear(); 
           
  32.         } 
       
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement