示例#1
0
文件: driver.php 项目: hcvcastro/pxp
 /**
  * Nombre funcion:	ejecutarConsultaIme
  * Proposito:		ejecuta la consulta de tipo insercion o modificacion o eliminacion
  * Fecha creacion:	12/04/2009
  * 
  */
 function ejecutarConsultaIme()
 {
     $array = array();
     $this->respuesta = new Mensaje();
     $cone = new conexion();
     if ($this->tipo_conexion == 'persistente') {
         $link = $cone->conectarp();
     } elseif ($this->tipo_conexion == 'seguridad') {
         $link = $cone->conectarSegu();
     } else {
         $link = $cone->conectarnp();
     }
     if ($link == 0) {
         $this->respuesta->setMensaje('ERROR', $this->nombre_archivo, 'No se puede conectar a la base de datos', 'Revise la cadena de conexion a la BD', 'modelo', $this->procedimiento, $this->transaccion, $this->tipo_procedimiento, $this->consulta);
     } else {
         //echo $this->consulta;
         //exit;
         if ($res = pg_query($link, $this->consulta)) {
             while ($row = pg_fetch_array($res, NULL, PGSQL_ASSOC)) {
                 array_push($array, $row);
             }
             //Libera la memoria
             pg_free_result($res);
             //Verifica si se produjo algon error logico en la funcion
             $resp_procedimiento = $this->divRespuesta($array[0]['f_intermediario_ime']);
             if ($this->uploadFile) {
                 $this->respuesta->setMensaje($resp_procedimiento['tipo_respuesta'], $this->nombre_archivo, $resp_procedimiento['mensaje'], $resp_procedimiento['mensaje_tec'], 'base', $this->procedimiento, $this->transaccion, $this->tipo_procedimiento, $this->parConsulta);
             } else {
                 $this->respuesta->setMensaje($resp_procedimiento['tipo_respuesta'], $this->nombre_archivo, $resp_procedimiento['mensaje'], $resp_procedimiento['mensaje_tec'], 'base', $this->procedimiento, $this->transaccion, $this->tipo_procedimiento, $this->consulta);
             }
             $this->respuesta->setDatos($resp_procedimiento['datos']);
         } else {
             $resp_procedimiento = $this->divRespuesta(str_replace('ERROR:  ', '', pg_last_error($link)));
             $this->respuesta->setDatos($resp_procedimiento['datos']);
             if ($this->uploadFile) {
                 $this->respuesta->setMensaje('ERROR', $this->nombre_archivo, $resp_procedimiento['mensaje'], $resp_procedimiento['mensaje_tec'], 'base', $this->procedimiento, $this->transaccion, $this->tipo_procedimiento, $this->parConsulta);
             } else {
                 $this->respuesta->setMensaje('ERROR', $this->nombre_archivo, $resp_procedimiento['mensaje'], $resp_procedimiento['mensaje_tec'], 'base', $this->procedimiento, $this->transaccion, $this->tipo_procedimiento, $this->consulta);
             }
         }
     }
     $cone->desconectarnp($link);
 }
示例#2
0
 function cargarDatosTablaProceso($link = 0)
 {
     //Definicion de variables para ejecucion del procedimientp
     $this->procedimiento = 'wf.ft_tabla_sel';
     $this->transaccion = 'WF_tabla_SEL';
     $this->tipo_procedimiento = 'SEL';
     //tipo de transaccion
     $this->setCount(false);
     $this->resetParametros();
     $this->resetCaptura();
     $primera_vez = 1;
     $this->setParametrosConsulta();
     //obtener los datos de la tabla maestro (datos de tabla y columnas)
     $this->captura('id_tabla', 'int4');
     $this->captura('id_tipo_proceso', 'int4');
     $this->captura('vista_id_tabla_maestro', 'int4');
     $this->captura('bd_scripts_extras', 'text');
     $this->captura('vista_campo_maestro', 'varchar');
     $this->captura('vista_scripts_extras', 'text');
     $this->captura('bd_descripcion', 'text');
     $this->captura('vista_tipo', 'varchar');
     $this->captura('menu_icono', 'varchar');
     $this->captura('menu_nombre', 'varchar');
     $this->captura('vista_campo_ordenacion', 'varchar');
     $this->captura('vista_posicion', 'varchar');
     $this->captura('estado_reg', 'varchar');
     $this->captura('menu_codigo', 'varchar');
     $this->captura('bd_nombre_tabla', 'varchar');
     $this->captura('bd_codigo_tabla', 'varchar');
     $this->captura('vista_dir_ordenacion', 'varchar');
     $this->captura('fecha_reg', 'timestamp');
     $this->captura('id_usuario_reg', 'int4');
     $this->captura('id_usuario_mod', 'int4');
     $this->captura('fecha_mod', 'timestamp');
     $this->captura('usr_reg', 'varchar');
     $this->captura('usr_mod', 'varchar');
     $this->captura('nombre_tabla_maestro', 'varchar');
     $this->captura('vista_estados_new', 'text');
     $this->captura('vista_estados_delete', 'text');
     $this->armarConsulta();
     if ($link == 0) {
         $cone = new conexion();
         $link = $cone->conectarnp();
         $primera_vez = 0;
     }
     $array = array();
     try {
         $res = pg_query($link, $this->consulta);
     } catch (Exception $e) {
         $this->respuesta = new Mensaje();
         $resp_procedimiento = $this->divRespuesta(str_replace('ERROR:  ', '', pg_last_error($link)));
         $this->respuesta->setMensaje('ERROR', $this->nombre_archivo, $resp_procedimiento['mensaje'], $resp_procedimiento['mensaje_tec'], 'base', $this->procedimiento, $this->transaccion, $this->tipo_procedimiento, $this->consulta);
         return $this->respuesta;
     }
     if ($res) {
         $i = 0;
         while ($row = pg_fetch_array($res, NULL, PGSQL_ASSOC)) {
             //obtener las columnas
             $array[$i] = array();
             $array[$i]['atributos'] = $row;
             $this->arreglo_consultas['filtro'] = ' tipcol.id_tabla = ' . $row['id_tabla'];
             $columnas = $this->cargarDatosColumnaProceso($link);
             //llama a la funcion para obtener atributos de una tabla
             //var_dump($columnas);exit;
             if ($columnas instanceof Mensaje) {
                 //Si es instancia de mensaje
                 return $columnas;
             }
             //retornar en mensaje
             $array[$i]['columnas'] = $columnas;
             //obtener las tablas
             //se cambia el filtro para la siguiente consulta
             $this->arreglo_consultas['filtro'] = ' tabla.vista_id_tabla_maestro = ' . $row['id_tabla'];
             $tablas = $this->cargarDatosTablaProceso($link);
             //Llama a esta misma funcion que me devolvera las tablas detalle
             if ($tablas instanceof Mensaje) {
                 //Si es instancia de mensaje
                 return $tablas;
             }
             //retornar en mensaje
             $array[$i]['detalles'] = $tablas;
             $i++;
         }
         pg_free_result($res);
     } else {
         $resp_procedimiento = $this->divRespuesta(str_replace('ERROR:  ', '', pg_last_error($link)));
         //Existe error en la base de datos tomamamos el mensaje y elmensaje tecnico
         $this->respuesta = new Mensaje();
         $this->respuesta->setMensaje('ERROR', $this->nombre_archivo, $resp_procedimiento['mensaje'], $resp_procedimiento['mensaje_tec'], 'base', $this->procedimiento, $this->transaccion, $this->tipo_procedimiento, $this->consulta);
         return $this->respuesta;
     }
     if ($primera_vez == 0) {
         $this->respuesta = new Mensaje();
         $this->respuesta->setMensaje('EXITO', $this->nombre_archivo, 'Consulta ejecutada con exito', 'Consulta ejecutada con exito', 'base', $this->procedimiento, $this->transaccion, $this->tipo_procedimiento, $this->consulta);
         $this->respuesta->setDatos($array);
         return $this->respuesta;
     } else {
         return $array;
     }
 }
示例#3
0
 function generarDocumento()
 {
     //Definicion de variables para ejecucion del procedimiento
     //1. Se obtiene las columas de la vista de base de datos
     $this->procedimiento = 'wf.ft_tipo_documento_sel';
     $this->transaccion = 'WF_TIDOCPLAN_SEL';
     $this->tipo_procedimiento = 'SEL';
     $this->setCount(false);
     $this->resetParametros();
     $this->resetCaptura();
     $this->setParametrosConsulta();
     //Definición de columnas
     $this->captura('column_name', 'varchar');
     $this->captura('data_type', 'varchar');
     $this->captura('character_maximum_length', 'int4');
     $this->setParametro('nombre_vista', 'nombre_vista', 'varchar');
     //Ejecuta la instruccion
     $this->armarConsulta();
     if ($link == 0) {
         $cone = new conexion();
         $link = $cone->conectarnp();
         $primera_vez = 0;
     }
     $array = array();
     try {
         $res = pg_query($link, $this->consulta);
         if ($res) {
             $i = 0;
             while ($row = pg_fetch_array($res, NULL, PGSQL_ASSOC)) {
                 //obtener las columnas
                 array_push($array, $row);
             }
             pg_free_result($res);
             if (count($array) == 0) {
                 $resp_procedimiento = $this->divRespuesta(str_replace('ERROR:  ', '', pg_last_error($link)));
                 //Existe error en la base de datos tomamamos el mensaje y elmensaje tecnico
                 $this->respuesta = new Mensaje();
                 $this->respuesta->setMensaje('ERROR', 'MODTipoDocumento.php', 'El Documento no tiene una vista de base de datos asociado.', 'El Documento no tiene una vista de base de datos asociada.', 'Control', $this->procedimiento, $this->transaccion, $this->tipo_procedimiento, $this->consulta);
                 return $this->respuesta;
             }
             ////////////////////////////////////////////////////////////////////
             //Obtención de la definición de columnas de la vista del documento
             ////////////////////////////////////////////////////////////////////
             $arrDefCols = array();
             $i = 0;
             foreach ($array as $clave => $valor) {
                 $j = 0;
                 foreach ($valor as $clave1 => $valor1) {
                     $arrDefCols[$i][$j] = $valor1;
                     $j++;
                 }
                 $i++;
             }
             //var_dump($arrDefCols);exit;
             ///////////////////////////////////////////////////////////
             //2. Ejecución de consulta para obtener los datos de la vista de base de datos
             ///////////////////////////////////////////////////////////
             $this->procedimiento = 'wf.ft_tipo_documento_sel';
             $this->transaccion = 'WF_VISTA_SEL';
             $this->tipo_procedimiento = 'SEL';
             $this->setCount(false);
             $this->resetParametros();
             $this->resetCaptura();
             $this->setParametrosConsulta();
             //Definición de columnas
             foreach ($arrDefCols as $clave => $valor) {
                 $columna = array();
                 $j = 0;
                 foreach ($valor as $clave1 => $valor1) {
                     $columna[$j] = $valor1;
                     $j++;
                 }
                 //echo $columna[0] .': '.$columna[1];
                 $this->captura($columna[0], $columna[1]);
             }
             //Envío de parámetro id_proceso_wf
             $this->setParametro('id_proceso_wf', 'id_proceso_wf', 'int4');
             $this->setParametro('nombre_vista', 'nombre_vista', 'varchar');
             $this->setParametro('esquema_vista', 'esquema_vista', 'varchar');
             //Ejecuta la instruccion
             $this->armarConsulta();
             //echo $this->consulta;exit;
             $this->ejecutarConsulta();
             return $this->respuesta;
         } else {
             $resp_procedimiento = $this->divRespuesta(str_replace('ERROR:  ', '', pg_last_error($link)));
             //Existe error en la base de datos tomamamos el mensaje y elmensaje tecnico
             $this->respuesta = new Mensaje();
             $this->respuesta->setMensaje('ERROR', $this->nombre_archivo, $resp_procedimiento['mensaje'], $resp_procedimiento['mensaje_tec'], 'base', $this->procedimiento, $this->transaccion, $this->tipo_procedimiento, $this->consulta);
             return $this->respuesta;
         }
     } catch (Exception $e) {
         $this->respuesta = new Mensaje();
         $resp_procedimiento = $this->divRespuesta(str_replace('ERROR:  ', '', pg_last_error($link)));
         $this->respuesta->setMensaje('ERROR', $this->nombre_archivo, $resp_procedimiento['mensaje'], $resp_procedimiento['mensaje_tec'], 'base', $this->procedimiento, $this->transaccion, $this->tipo_procedimiento, $this->consulta);
         return $this->respuesta;
     }
 }