示例#1
0
 /**
  * Guardar la informacion de los tipos de definicion y los valores
  *
  */
 function guardar_definicion($dato = array())
 {
     $db = new ClassConexion();
     $db->begin();
     try {
         $query = "  INSERT INTO tipo_definicion (tipo_definicion, activo, fecha_creacion, usuario_creador)\r\n                        VALUES ('" . $dato['tipo_def'] . "', '" . $dato['estado_def'] . "', NOW(), '" . $_SESSION['nombre'] . "' )";
         $db->consulta($query, 'INSERT');
         $id_padre = $db->insert_id();
         if (isset($id_padre) && $id_padre != '' && !is_null($id_padre)) {
             for ($i = 0; $i < count($dato['detalle']); $i++) {
                 $query = "  INSERT INTO valores_definiciones (\r\n                                id_tipo_definicion,\r\n                                valor_definicion,\r\n                                desc_valor_def,\r\n                                tipo_valor_def,\r\n                                activo,\r\n                                fecha_creacion,\r\n                                usuario_creador\r\n                                ) VALUES (\r\n                                '{$id_padre}'\r\n                                ,'" . $dato['detalle'][$i]['valor_def'] . "'\r\n                                ,'" . $dato['detalle'][$i]['desc_def'] . "'\r\n                                ,'" . $dato['tipo_def'] . "'\r\n                                ,'" . $dato['detalle'][$i]['estado_def'] . "'\r\n                                ,NOW()\r\n                                ,'" . $_SESSION['nombre'] . "'\r\n                                )";
                 $db->consulta($query, 'INSERT');
                 $id_hijo[] = $db->insert_id();
             }
         }
     } catch (Exception $e) {
         $db->rollback();
         return $e;
     }
     if ($id_padre != '' && !is_null($id_padre) && count($id_hijo) > 0 && isset($id_hijo)) {
         $db->commit();
         return true;
     }
 }