Ver Mensaje Individual
  #3 (permalink)  
Antiguo 12/07/2011, 14:06
GUILLHERMOSOFT
 
Fecha de Ingreso: marzo-2009
Ubicación: Cali (Valle) - Colombia
Mensajes: 164
Antigüedad: 15 años, 1 mes
Puntos: 2
De acuerdo Respuesta: Transacción con bucle (ciclo) con PostgreSQL y PHP-PDO

Hola huesos52, gracias por tu ayuda, sin embargo, ya lo solucioné, mi código quedo así:

Código:
$consulta = "INSERT INTO \"datosComercialesClientes\" (\"idCliente\", \"celular\", \"fax\", \"email\", \"diasPlazoCredito\", \"descuentoProntoPago\", \"descuentoComercial\", \"estadoRegistro\", \"creadoPor\", \"creadoEn\")
                    VALUES ($idCliente, NULL, NULL, '', NULL, NULL, NULL, '1', '$idCreador', 'now'::text::timestamp without time zone)";
        $guarda = $this->db->prepare($consulta);
        try {
            $this->db->beginTransaction();
            $guarda->execute();
            for ($i = 0; $i < count($this->_referenciaComercialCliente); $i++) {                   
                $consulta = "INSERT INTO \"referenciasComercialesClientes\" (\"idCliente\",\"referenciaComercialCliente\",\"montoCredito\",\"anosAntiguedad\",\"telefono\", \"estadoRegistro\", \"creadoPor\", \"creadoEn\")
                            VALUES ($idCliente, ?, ?, ?, ?, '1', '$idCreador', 'now'::text::timestamp without time zone)";
                $guarda = $this->db->prepare($consulta);
                $this->_montoCredito[$i] = str_replace(array(",", "$"), "", $this->_montoCredito[$i]);
                $guarda->execute(array($this->_referenciaComercialCliente[$i], $this->_montoCredito[$i], $this->_anosAntiguedadReferenciaComercial[$i], $this->_telefonoReferenciaComercial[$i]));
            }
            $this->db->commit();
            return true;
        } catch (PDOException $e) {
            $this->db->rollback();
            return false;
        }
Por si alguno tiene la misma duda, quizás le sea útil.

Última edición por GUILLHERMOSOFT; 13/07/2011 a las 10:26