Ver Mensaje Individual
  #3 (permalink)  
Antiguo 30/11/2011, 20:30
yoelkj
 
Fecha de Ingreso: marzo-2009
Ubicación: Lima
Mensajes: 73
Antigüedad: 15 años, 1 mes
Puntos: 1
Respuesta: Actualiza miles de registros al mismo tiempo

Cita:
Iniciado por Panga Ver Mensaje
Buenas,
Si podrias ponernos el codigo, para ver como lo tenes, asi vamos viendo en que te podemos ayudar.
Estoy con symfony

Código PHP:
Ver original
  1. public function executeGenerate($id=null){
  2.        
  3.         //lista productos
  4.         $P = Doctrine_Query::create()->select('p.id, p.referencia')->from('Productos p');
  5.         $productos = $P->fetchArray();
  6.        
  7.         //lista tallas
  8.         $T = Doctrine_Query::create()->select('t.id, t.nombre')->from('Tallas t');
  9.         $tallas = $T->fetchArray();
  10.        
  11.         //lista colores
  12.         $C = Doctrine_Query::create()->select('c.id, c.referencia')->from('Colores c');
  13.         $colores = $C->fetchArray();
  14.        
  15.         $listJoin=array();
  16.        
  17.         ini_set("memory_limit","200M");
  18.         set_time_limit(1200);
  19.        
  20.         $i=1;
  21.         $noChar = array(" ", "/", "-");
  22.         foreach($productos as $producto){
  23.             foreach($colores as $color){
  24.                 foreach($tallas as $talla){
  25.                     $combina = new Combinaciones();
  26.                     //$listJoin[] = $producto['referencia'].$color['referencia'].$talla['nombre'];
  27.                     $combina->fromArray(array(
  28.                       'activo'          => true,
  29.                       'nombre'          => str_replace($noChar, "", $producto['referencia'].$color['referencia'].$talla['nombre']),
  30.                       'productos_id'    => $producto['id'],
  31.                       'tallas_id'       => $talla['id'],
  32.                       'colores_id'      => $color['id'],
  33.                     ));
  34.                     $combina->save();
  35.                 }
  36.             }
  37.         }
  38.         //$this->listJoin = $listJoin;
  39.         $this->redirect('combinaciones/index');
  40. }

Este es mi actual código pero demora mucho tiempo en ejecutarse.

gracias por responder

Última edición por yoelkj; 30/11/2011 a las 20:33 Razón: colocar Highlight