Herramientas Informaticas

Autor: juliocesar20200413 Página 18 de 139

Desarrollador web apasionado y gusto por la buena musica

Administradores Visuales de MariaDB/MySQL

Hemos visto en la publicación anterior como conectarnos a MariaDB por medio de la consola, que por cierto falto poner el puerto así que en la ultima publicación asi que realmente nos conectamos a la instancia del 3306.

Bien al grano, existen muchas herramientas de administración de base de datos MariaDB pero les mostrare las que mas he usado y sigo usando

Comandos Básicos de introducción MariaDB desde consola, Select Where

En este tutorial veremos algunos comandos básicos desde la consola y si ya se que se preguntan por que conectarnos por la consola de comandos en lugar de un GUI como puede ser Workbench HeidiSQL etc, es muy necesario sobre todo si eres programador ya que solo se usan comandos y créeme no es que vallas a usar la consola todo el tiempo pero si aprender los comandos en lugar de crear las tablas desde GUI se te va a dificultar mas, de hecho conforme pasa el tiempo y van creciendo las tablas en lo referente a columnas por la misma experiencia se les hará mas fácil manejarse con comandos.

Bien para conectarnos nos posicionamos en el directorio de instalación de mariaDB que es C:\Program Files\MariaDB 10.6\bin y para conectarnos usaremos el siguiente comando

CURSO MARIADB – INSTALACIÓN / CONFIGURACIÓN

Ya hemos terminado el tutorial de programación básica en Visual Basic 2022 Community, ahora vamos a ver una ligera introducción a las base de datos.

Vamos al grano, cuando usamos un sistema de gestión empresarial, de contenidos, o simplemente un programa en donde exista almacenamiento y flujo de información se usara bases de datos para su respectivo tratamiento, mantenimiento y presentación a Trávez de reportes.

Existe diferentes manejadores de bases de datos, estan desde lo de paga hasta los gratuitos, desde código abierto como código cerrado, como ejemplo estan los siguientes:

  1. MySQL
  2. SQL Server
  3. SQLite
  4. MariaDB
  5. MongoDB

En esta serie de tutoriales vamos a dar un curso sobre el gestor de base de datos de código abierto mas extendido y que viene siendo un estándar en el desarrollo de sistemas web ya que lo van encontrar en la mayoría de los hosting Web y es MariaDB

JCPOSCREATOR CREADOR DE CATALOGOS PHP EN BASE EN LA TABLA

Que tal amigos, les voy a dejar esta herramienta con la cual podrán crear catalogo en tiempo récord, solo es necesario crear la tabla en MySQL con la columna id Primeria y con los demás campos que se necesite.

Esta herramienta es muy útil para reducir el tiempo de desarrollo ya que las actividades repetitivas las haremos muy rápido sin tanto esfuerzo

A continuación les dejo el manual

Primero creamos la tabla, en este ejemplo crearemos la tabla tiposGasto con la columna id como llave primeria, y las columnas descripcion, cuentaContable,subCuentaContrable les dejo el código SQL

Crear Ejecutable del programa Visual Basic 2022

Y bien ya tenemos nuestro código fuente terminado, ahora lo que sigue poder distribuir nuestro programa para ello vamos a crear el ejecutable a continuación mostramos como hacerlo

Primero Elegimos una carpeta fácil de ubicar, por ejemplo, nosotros crearnos una carpeta llamada resultado en el escritorio.

En visual Studio 2022 Community, en el proyecto nos vamos al menú compilar y después elegimos publicar, nos saldrá la siguiente ventana.

Seleccionamos la opción Carpeta
Elegimos la opción Carpeta
Elegimos la ubicación donde se va a generar el ejecutable
En la configuración le ponemos Producir un único archivo y ReadyToRun
Finalmente de damos click en publicar y nos va a generar el EXE
Y listo ya tenemos nuestro ejecutable listo para usar

Saludos en el proximo video veremos como subir nuestro proyecto a source forge

Como guardar archivos generados en texto en archivo

Ya vimos como generar el texto del modelo, vista y controlador tomando en base solo una tabla de MariaDB/MySQL tomando las columnas y campos con llave primaria, ahora lo que nos falta por hacer es guardar esa información en archivos .PHP en el proyecto para ello simplemente hacemos lo siguiente.

Primero guardamos en registro de windows la ruta para que se valla quedando guardando como default, esto lo hacemos al darle click al botón aceptar.

Lo hacemos con el siguiente código

   'Guardamos en el registro de windows la variable de txtTabla
       My.Computer.Registry.SetValue("HKEY_CURRENT_USER\CREADORMVCPHP", "txtRuta", Me.txtRuta.Text)

Luego en el evento load de la ventana creador de cátalogo agregamos para leer la variable donde guardamos la ruta del registro de windows

  'Leemos la variable por default de la ruta desde el registro de windows
        If Not My.Computer.Registry.GetValue("HKEY_CURRENT_USER\CREADORMVCPHP", "txtRuta", Nothing) Is Nothing Then

            Me.txtRuta.Text = My.Computer.Registry.GetValue("HKEY_CURRENT_USER\CREADORMVCPHP", "txtRuta", Nothing).ToString()

        End If

Ya por ultimo grabamos los textos en los archivos correspondientes, es importante usar la codificación ASCII para evitar errores en el ajax

        'GUARDAMOS LOS ARCHIVOS

        'GUARDAMOS MODELO EN EL ARCHIVO
        My.Computer.FileSystem.WriteAllText(Me.txtRuta.Text & "/modelos/" & txtTabla.Text & ".modelo.php", strModelo, False, System.Text.Encoding.ASCII)

        'GUARDAMOS CONTROLADOR EN EL ARCHIVO
        My.Computer.FileSystem.WriteAllText(Me.txtRuta.Text & "/controladores/" & txtTabla.Text & ".controlador.php", strControlador, False, System.Text.Encoding.ASCII)

        'GUARDAMOS VISTA EN EL ARCHIVO
        My.Computer.FileSystem.WriteAllText(Me.txtRuta.Text & "/vistas/modulos/" & txtTabla.Text & ".php", strVista, False, System.Text.Encoding.ASCII)

Y listo ya con esto nos debe crear los archivos

Solo tendremos que crear manualmente el menú y agregar en plantilla.php para que corra la visa

Saludos en el próximo video veremos como subir el proyecto para que lo puedan descargar

Creando texto para vista PHP8 en base a la tabla usando Visual Basic 2022

Ahora solo queda hacer la función para generar automáticamente el código HTML/PHP para la vista del catalogo en base a la nueva tabla.

La lógica es igual solo que es otro texto

Insertamos el siguiente código

'IMPORTAMOS LAS LIBRERIAS NECESARIAS PARA LA CONEXIÓN A MYSQL/MARIADB
Imports MySqlConnector.MySqlConnection

'EMPIEZA EL MODULO
Module crearVista

    ' CON PUBLIC SUB CREAMOS PROCEDIMIENTOS
    Public Function generarVista() As String

        ' VARIABLES PARA LA CONEXIÓN
        Dim strServidor As String
        Dim strBaseDeDatos As String
        Dim strUsuario As String
        Dim strContra As String

        'Variables de uso
        Dim contador As Integer
        Dim strEncabezadosTabla As String
        Dim strCampos As String
        Dim strControlesNuevos As String
        Dim strControlesEditar As String
        Dim strEditarJS As String
        Dim strBloquear As String
        Dim strEditarTraeDatos As String
        Dim strDatos As String
        Dim strLLavePrimaria As String
        Dim strVista As String
        Dim strSegundoCampo As String

        contador = 0
        strEncabezadosTabla = ""
        strCampos = ""
        strControlesNuevos = ""
        strEditarJS = ""
        strDatos = ""

        'OBTENEMOS LOS DATOS DE CONFIGURACIÖN DEL REGISTRO DE WINDOWS PREVIAMENTE GUARDADAS
        If Not My.Computer.Registry.GetValue("HKEY_CURRENT_USER\CREADORMVCPHP", "servidor", Nothing) Is Nothing Then
            strServidor = My.Computer.Registry.GetValue("HKEY_CURRENT_USER\CREADORMVCPHP", "servidor", Nothing).ToString()
            strBaseDeDatos = My.Computer.Registry.GetValue("HKEY_CURRENT_USER\CREADORMVCPHP", "baseDeDatos", Nothing).ToString()
            strUsuario = My.Computer.Registry.GetValue("HKEY_CURRENT_USER\CREADORMVCPHP", "usuario", Nothing).ToString()
            strContra = My.Computer.Registry.GetValue("HKEY_CURRENT_USER\CREADORMVCPHP", "contra", Nothing).ToString()
        Else

            MsgBox("No se han capturado la conexión a la base de datos")
            Exit Function


        End If


        ' METEMOS LA CADENA DE CONEXIÓN EN UNA VARIABLE
        Dim cadenaConexion = "Server=" & strServidor & ";User ID=" & strUsuario & ";Password=" & strContra & ";Database=" & strBaseDeDatos

        ' CREAMOS LA CONEXIÓN CON LA CADENA DE CONEXIÓN
        Dim connection = New MySqlConnector.MySqlConnection(cadenaConexion)

        Try


            connection.Open()
            Dim comando = New MySqlConnector.MySqlCommand("delete from clases where clase= 'controladores/" & frmCreaCatalogo.txtTabla.Text & ".controlador.php'", connection)
            Dim resultado = comando.ExecuteReader()
            comando = Nothing
            resultado = Nothing
            connection.Close()



            connection.Open()
            comando = New MySqlConnector.MySqlCommand("delete from clases where clase= 'modelos/" & frmCreaCatalogo.txtTabla.Text & ".modelo.php'", connection)
            resultado = comando.ExecuteReader()
            comando = Nothing
            resultado = Nothing
            connection.Close()

            connection.Open()
            comando = New MySqlConnector.MySqlCommand("insert into clases(clase) values('controladores/" & frmCreaCatalogo.txtTabla.Text & ".controlador.php')", connection)
            resultado = comando.ExecuteReader()
            comando = Nothing
            resultado = Nothing
            connection.Close()

            connection.Open()
            comando = New MySqlConnector.MySqlCommand("insert into clases(clase) values( 'modelos/" & frmCreaCatalogo.txtTabla.Text & ".modelo.php')", connection)
            resultado = comando.ExecuteReader()
            comando = Nothing
            resultado = Nothing
            connection.Close()

            ' SI SE ABRE LA CONEXIÓN MANDAMOS MENSAJE
            connection.Open()




            comando = New MySqlConnector.MySqlCommand("SHOW KEYS FROM  " & frmCreaCatalogo.txtTabla.Text & " WHERE Key_name = 'PRIMARY'", connection)

            resultado = comando.ExecuteReader

            resultado.Read()


            'ASIGNAMOS EL CAMPO LLAVE

            strLLavePrimaria = resultado.GetString("Column_name")


            'OBTENEMOS LOS CAMPOS DE LA TABLA
            connection.Close()
            connection.Open()
            comando = Nothing
            comando = New MySqlConnector.MySqlCommand("describe  " & frmCreaCatalogo.txtTabla.Text & "", connection)
            resultado = Nothing
            resultado = comando.ExecuteReader



            contador = 0


            While (resultado.Read)
                strEncabezadosTabla &= "<th>" & utilerias.strPrimeraMayuscula(resultado("Field")) & "</th>" & vbCrLf

                strCampos &= "<td>'.$value[""" & resultado("Field") & """].'</td>" & vbCrLf

                If contador > 0 Then

                    strControlesNuevos &= "" & "            <!-- ENTRADA PARA " & UCase(resultado("Field")) & " --> " & vbCrLf
                    strControlesNuevos &= "" & " " & vbCrLf
                    strControlesNuevos &= "" & "            <div class=""form-group""> " & vbCrLf
                    strControlesNuevos &= "" & " " & vbCrLf
                    strControlesNuevos &= "" & "              <div class=""input-group""> " & vbCrLf
                    strControlesNuevos &= "" & " " & vbCrLf
                    strControlesNuevos &= "" & "                <span class=""input-group-addon"">" & utilerias.strPrimeraMayuscula(resultado("Field")) & ": </span>  " & vbCrLf
                    strControlesNuevos &= "" & " " & vbCrLf
                    strControlesNuevos &= "" & "                <input type=""text"" class=""form-control input-lg"" name=""nuevo" & utilerias.strPrimeraMayuscula(resultado("Field")) & """ placeholder=""Ingresar " & utilerias.strPrimeraMayuscula(resultado("Field")) & """ required> " & vbCrLf
                    strControlesNuevos &= "" & " " & vbCrLf
                    strControlesNuevos &= "" & "              </div> " & vbCrLf
                    strControlesNuevos &= "" & " " & vbCrLf
                    strControlesNuevos &= "" & "            </div> " & vbCrLf

                    strEditarJS &= "" & "            $(""#editarDescripcion"").val(respuesta[""descripcion""]);" & vbCrLf

                End If


                If resultado("Key") = "PRI" Then
                    strBloquear = "readonly"
                Else
                    strBloquear = ""
                End If



                strControlesEditar &= "" & "            <!-- ENTRADA PARA " & UCase(resultado("Field")) & " --> " & vbCrLf
                strControlesEditar &= "" & " " & vbCrLf
                strControlesEditar &= "" & "            <div class=""form-group""> " & vbCrLf
                strControlesEditar &= "" & " " & vbCrLf
                strControlesEditar &= "" & "              <div class=""input-group""> " & vbCrLf
                strControlesEditar &= "" & " " & vbCrLf
                strControlesEditar &= "" & "                <span class=""input-group-addon"">" & utilerias.strPrimeraMayuscula(resultado("Field")) & ": </span>  " & vbCrLf
                strControlesEditar &= "" & " " & vbCrLf
                strControlesEditar &= "" & "                <input " & strBloquear & "  type=""text"" class=""form-control input-lg"" id=""editar" & utilerias.strPrimeraMayuscula(resultado("Field")) & """ name=""editar" & utilerias.strPrimeraMayuscula(resultado("Field")) & """ placeholder=""Ingresar " & utilerias.strPrimeraMayuscula(resultado("Field")) & """ required> " & vbCrLf
                strControlesEditar &= "" & " " & vbCrLf
                strControlesEditar &= "" & "              </div> " & vbCrLf
                strControlesEditar &= "" & " " & vbCrLf
                strControlesEditar &= "" & "            </div> " & vbCrLf

                strEditarTraeDatos &= "" & "            $(""#editar" & utilerias.strPrimeraMayuscula(resultado("Field")) & """).val(respuesta[""" & resultado("Field") & """]); " & vbCrLf

                contador = contador + 1

            End While


            strControlesEditar &= "" & " <input type=""hidden"" id=""editar" & utilerias.strPrimeraMayuscula(frmCreaCatalogo.txtTabla.Text) & """  name = ""editar" & utilerias.strPrimeraMayuscula(frmCreaCatalogo.txtTabla.Text) & """ > " & vbCrLf
            strEncabezadosTabla &= "<th>Acciones</th>"
            strCampos &= "<td> " & vbCrLf
            strCampos &= "<div class = ""btn-group""> " & vbCrLf



            strCampos &= "                    <button class= ""btn btn-warning btnEditar" & utilerias.strPrimeraMayuscula(frmCreaCatalogo.txtTabla.Text) & """ id" & utilerias.strPrimeraMayuscula(frmCreaCatalogo.txtTabla.Text) & " = ""'.$value[""id""].'"" data-toggle = ""modal"" data-target = ""#modalEditar" & Trim(utilerias.strPrimeraMayuscula(frmCreaCatalogo.txtTabla.Text)) & """> <i class = ""fa fa-pencil""> </i> </button> " & vbCrLf

            strCampos &= "<button class = ""btn btn-danger btnEliminar" & utilerias.strPrimeraMayuscula(frmCreaCatalogo.txtTabla.Text) & """ id" & utilerias.strPrimeraMayuscula(frmCreaCatalogo.txtTabla.Text) & "= ""'.$value[""id""].'""><i class= ""fa fa-times""></i></button>" & vbCrLf

            strCampos &= "</div>" & vbCrLf

            strCampos &= "</td> " & vbCrLf

            strVista &= "" & "<?php" & vbCrLf
            strVista &= "" & vbCrLf
            strVista &= "" & "if(""off"" == ""offf""){" & vbCrLf
            strVista &= "" & vbCrLf
            strVista &= "" & "  echo '<script>" & vbCrLf
            strVista &= "" & vbCrLf
            strVista &= "" & "    window.location = ""inicio""; " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "  </script>'; " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "  return; " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "} " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "?> " & vbCrLf
            strVista &= "" & "<div class=""content-wrapper"">" & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "  <section class=""content-header"">" & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "    <h1> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "      Administrar <?php echo  mb_strtolower(preg_replace('/(?<=\\w)(\\p{Lu})/u', ' $1', ' " & utilerias.strPrimeraMayuscula(frmCreaCatalogo.txtTabla.Text) & " ')); ?> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "    </h1> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "    <ol class=""breadcrumb""> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "      <li><a href=""inicio""><i class=""fa fa-dashboard""></i> Inicio</a></li> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "      <li class=""active"">Administrar <?php echo  mb_strtolower(preg_replace('/(?<=\\w)(\\p{Lu})/u', ' $1', '" & utilerias.strPrimeraMayuscula(frmCreaCatalogo.txtTabla.Text) & " ')); ?></li> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "    </ol> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "  </section> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "  <section class=""content""> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "    <div class=""box""> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "      <div class=""box-header With-border""> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "        <button class=""btn btn-primary"" data-toggle=""modal"" data-target=""#modalAgregar" & utilerias.strPrimeraMayuscula(frmCreaCatalogo.txtTabla.Text) & """> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "          Agregar <?php echo  mb_strtolower(preg_replace('/(?<=\\w)(\\p{Lu})/u', ' $1', '" & utilerias.strPrimeraMayuscula(frmCreaCatalogo.txtTabla.Text) & " ')); ?> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "        </button> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "      </div> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "      <div class=""box-body""> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "       <table class=""table table-bordered table-striped dt-responsive tablas"" width=""100%""> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "        <thead> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "         <tr> " & vbCrLf
            strVista &= "" & " " & strEncabezadosTabla
            strVista &= "" & "         </tr>  " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "        </thead> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "        <tbody> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "        <?php " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "        $item = null; " & vbCrLf
            strVista &= "" & "        $valor = null; " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "        $" & frmCreaCatalogo.txtTabla.Text & "= Controlador" & utilerias.strPrimeraMayuscula(frmCreaCatalogo.txtTabla.Text) & "::ctrMostrar($item, $valor); " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "       foreach ($" & frmCreaCatalogo.txtTabla.Text & " as $key => $value){ " & vbCrLf
            strVista &= "" & " " & vbCrLf



            strVista &= "" & "          echo ' <tr> " & vbCrLf

            strVista &= "" & strCampos & vbCrLf

            strVista &= "" & " " & vbCrLf
            strVista &= "" & "                </tr>'; " & vbCrLf
            strVista &= "" & "        } " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "        ?>  " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "        </tbody> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "       </table> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "      </div> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "    </div> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "  </section> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "</div> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "<!--===================================== " & vbCrLf
            strVista &= "" & "MODAL <?php echo  mb_strtolower(preg_replace('/(?<=\\w)(\\p{Lu})/u', ' $1', ' " & (frmCreaCatalogo.txtTabla.Text) & " ')); ?> " & vbCrLf
            strVista &= "" & " ======================================--> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "<div id=""modalAgregar" & utilerias.strPrimeraMayuscula(frmCreaCatalogo.txtTabla.Text) & """ class=""modal fade"" role=""dialog""> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "  <div class=""modal-dialog""> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "    <div class=""modal-content""> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "      <form role=""form"" method=""post"" enctype=""multipart/form-data""> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "        <!--===================================== " & vbCrLf
            strVista &= "" & "        CABEZA DEL MODAL " & vbCrLf
            strVista &= "" & "        ======================================--> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "        <div class=""modal-header"" style=""background:#3c8dbc; color:white"" > " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "          <button type=""button"" class=""close"" data-dismiss=""modal"">&times;</button> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "          <h4 class=""modal-title"">Agregar <?php echo  mb_strtolower(preg_replace('/(?<=\\w)(\\p{Lu})/u', ' $1', ' " & (frmCreaCatalogo.txtTabla.Text) & " ')); ?> </h4> " & vbCrLf
            strVista &= "" & " " & vbCrLf

            strVista &= "" & "        </div> " & vbCrLf

            strVista &= "" & "        <!--===================================== " & vbCrLf
            strVista &= "" & "        CUERPO DEL MODAL " & vbCrLf
            strVista &= "" & "        ======================================--> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "        <div class=""modal-body""> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "          <div class=""box-body""> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "            <!-- ENTRADA PARA DESCRIPCION --> " & vbCrLf

            strVista &= "" & " " & strControlesNuevos & vbCrLf


            strVista &= "" & " " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "          </div> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "        </div> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "        <!--===================================== " & vbCrLf
            strVista &= "" & "        PIE DEL MODAL " & vbCrLf
            strVista &= "" & "        ====================================== --> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "        <div class=""modal-footer""> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "          <button type=""button"" class=""btn btn-Default pull-left"" data-dismiss=""modal"">Salir</button> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "          <button type=""submit"" class=""btn btn-primary"">Guardar</button> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "        </div> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "        <?php " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "           $crear = new Controlador" & utilerias.strPrimeraMayuscula(frmCreaCatalogo.txtTabla.Text) & "(); " & vbCrLf
            strVista &= "" & "           $crear ->ctrIngresar(); " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "        ?> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "      </form> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "    </div> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "  </div> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "</div> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "<!--===================================== " & vbCrLf
            strVista &= "" & "MODAL EDITAR USUARIO " & vbCrLf
            strVista &= "" & " ======================================--> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "<div id=""modalEditar" & utilerias.strPrimeraMayuscula(frmCreaCatalogo.txtTabla.Text) & """ class=""modal fade"" role=""dialog"">" & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "  <div class=""modal-dialog""> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "    <div class=""modal-content""> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "      <form role=""form"" method=""post"" enctype=""multipart/form-data""> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "        <!--===================================== " & vbCrLf
            strVista &= "" & "        CABEZA DEL MODAL " & vbCrLf
            strVista &= "" & "        ======================================--> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "        <div class=""modal-header"" style=""background:#3c8dbc; color:white"" > " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "          <button type=""button"" class=""close"" data-dismiss=""modal"">&times;</button> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "          <h4 class=""modal-title"">Agregar <?php echo  mb_strtolower(preg_replace('/(?<=\\w)(\\p{Lu})/u', ' $1', ' " & (frmCreaCatalogo.txtTabla.Text) & " ')); ?> </h4> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "        </div> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "        <!--===================================== " & vbCrLf
            strVista &= "" & "        CUERPO DEL MODAL " & vbCrLf
            strVista &= "" & "        ======================================--> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "        <div class=""modal-body""> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "          <div class=""box-body""> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "            <!-- ENTRADA PARA DESCRIPCION --> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & strControlesEditar
            strVista &= "" & " " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "          </div> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "        </div> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "        <!--===================================== " & vbCrLf
            strVista &= "" & "        PIE DEL MODAL " & vbCrLf
            strVista &= "" & "        ======================================--> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "        <div class=""modal-footer""> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "          <button type=""button"" class=""btn btn-Default pull-left"" data-dismiss=""modal"">Salir</button> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "          <button type=""submit"" class=""btn btn-primary"">Modificar</button> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "        </div> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "     <?php " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "           $editar = new Controlador" & utilerias.strPrimeraMayuscula(frmCreaCatalogo.txtTabla.Text) & "(); " & vbCrLf
            strVista &= "" & "           $editar ->ctrEditar(); " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "        ?>  " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "      </form> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "    </div> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "  </div> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "</div> " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "<?php " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "   $borrar = new Controlador" & utilerias.strPrimeraMayuscula(frmCreaCatalogo.txtTabla.Text) & "(); " & vbCrLf
            strVista &= "" & "   $borrar ->ctrBorrar(); " & vbCrLf
            strVista &= "" & " " & vbCrLf
            strVista &= "" & "?>  " & vbCrLf

            'JAVASCRIPT FUNCIONES
            strVista &= "" & "<script type=""text/javascript"">" & vbCrLf

            'ELIMINAR


            strVista &= "" & "/*= == == == == == == == == == == == == == == == == == == == == == ==" & vbCrLf
            strVista &= "" & " ELIMINAR " & UCase(frmCreaCatalogo.txtTabla.Text) & vbCrLf
            strVista &= "" & " == == == == == == == == == == == == == == == == == == == == == == = */" & vbCrLf
            strVista &= "" & "$("".tablas "").on(""click"", "".btnEliminar" & utilerias.strPrimeraMayuscula(frmCreaCatalogo.txtTabla.Text) & """, function() {" & vbCrLf

            strVista &= "" & "    var id" & utilerias.strPrimeraMayuscula(frmCreaCatalogo.txtTabla.Text) & " = $(this).attr(""id" & frmCreaCatalogo.txtTabla.Text & """);" & vbCrLf

            strVista &= "" & "    swal( {" & vbCrLf
            strVista &= "" & "        title: '¿Está seguro de borrar?'," & vbCrLf
            strVista &= "" & "        text: ""¡Si no lo está puede cancelar la accíón!""," & vbCrLf
            strVista &= "" & "        type: 'warning'," & vbCrLf
            strVista &= "" & "        showCancelButton: true," & vbCrLf
            strVista &= "" & "        confirmButtonColor: '#3085d6'," & vbCrLf
            strVista &= "" & "        cancelButtonColor: '#d33'," & vbCrLf
            strVista &= "" & "        cancelButtonText: 'Cancelar'," & vbCrLf
            strVista &= "" & "       confirmButtonText: 'Si, borrar!'" & vbCrLf
            strVista &= "" & "    }).then(function(result) {" & vbCrLf
            strVista &= "" & "" & vbCrLf
            strVista &= "" & "        if (result.value) {" & vbCrLf
            strVista &= "" & "" & vbCrLf
            strVista &= "" & "            window.location = ""index.php?ruta=" & (frmCreaCatalogo.txtTabla.Text) & "&id" & utilerias.strPrimeraMayuscula(frmCreaCatalogo.txtTabla.Text) & "=""+id" & utilerias.strPrimeraMayuscula(frmCreaCatalogo.txtTabla.Text) & "+""&borrar" & utilerias.strPrimeraMayuscula(frmCreaCatalogo.txtTabla.Text) & "=borrar"";" & vbCrLf
            strVista &= "" & "" & vbCrLf
            strVista &= "" & "        }" & vbCrLf
            strVista &= "" & "" & vbCrLf
            strVista &= "" & "    })" & vbCrLf

            strVista &= "" & "})" & vbCrLf


            'editar

            strVista &= "" & "/* = == == == == == == == == == == == == == == == == == == == == == ==" & vbCrLf
            strVista &= "" & " EDITAR " & vbCrLf
            strVista &= "" & " == == == == == == == == == == == == == == == == == == == == == == = */" & vbCrLf
            strVista &= "" & "$("".tablas "").on(""click"", "".btnEditar" & utilerias.strPrimeraMayuscula(frmCreaCatalogo.txtTabla.Text) & """, function() {" & vbCrLf
            strVista &= "" & "" & vbCrLf
            strVista &= "" & "    var id" & utilerias.strPrimeraMayuscula(frmCreaCatalogo.txtTabla.Text) & " = $(this).attr(""id" & utilerias.strPrimeraMayuscula(frmCreaCatalogo.txtTabla.Text) & """);" & vbCrLf
            strVista &= "" & "  console.log(id" & utilerias.strPrimeraMayuscula(frmCreaCatalogo.txtTabla.Text) & ");"
            strVista &= "" & "" & vbCrLf
            strVista &= "" & "" & vbCrLf
            strVista &= "" & "    var datos = new FormData();" & vbCrLf
            strVista &= "" & "    datos.append(""id" & utilerias.strPrimeraMayuscula(frmCreaCatalogo.txtTabla.Text) & """, id" & utilerias.strPrimeraMayuscula(frmCreaCatalogo.txtTabla.Text) & "); " & vbCrLf
            strVista &= "" & "    datos.append(""buscar" & utilerias.strPrimeraMayuscula(frmCreaCatalogo.txtTabla.Text) & """, ""buscar" & utilerias.strPrimeraMayuscula(frmCreaCatalogo.txtTabla.Text) & """);" & vbCrLf
            strVista &= "" & "   " & vbCrLf
            strVista &= "" & "" & vbCrLf
            strVista &= "" & "    $.ajax( {" & vbCrLf
            strVista &= "" & "" & vbCrLf
            strVista &= "" & "        url:""controladores/" & frmCreaCatalogo.txtTabla.Text & ".controlador.php""," & vbCrLf
            strVista &= "" & "        method:""POST""," & vbCrLf
            strVista &= "" & "        data: datos," & vbCrLf
            strVista &= "" & "        cache: false," & vbCrLf
            strVista &= "" & "        contentType: false," & vbCrLf
            strVista &= "" & "        processData: false," & vbCrLf
            strVista &= "" & "       dataType:""json""," & vbCrLf
            strVista &= "" & "       success: function(respuesta) {" & vbCrLf
            strVista &= "" & "" & vbCrLf
            strVista &= "" & strEditarTraeDatos & vbCrLf
            strVista &= "" & "            " & vbCrLf
            strVista &= "" & "        }" & vbCrLf
            strVista &= "" & "" & vbCrLf
            strVista &= "" & "    });" & vbCrLf
            strVista &= "" & "" & vbCrLf
            strVista &= "" & "})" & vbCrLf


            strVista &= "" & "</script>" & vbCrLf
            Return strVista
        Catch ex As Exception
            ' SI NO SE ABRE LA CONEXIÓN MANDAMOS MENSAJE DE ERROR
            MsgBox("ERROR " & ex.Message)

            Exit Function
        End Try

    End Function

End Module

Creando texto para el archivo del catalogo controlador PHP Visual Basic 2022 en base a una tabla creada

Ya vimos como crear el modelo, dijimos que mostraremos como crear el archivo de modelo, pero mejor mostraremos como generar el texto del controlador en base a los campos de la tabla, es un poco mas fácil

a continuación les dejo el código fuente

Imports System.Windows.Forms

Public Class frmCreaCatalogo

    Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click

        Dim strModelo As String
        Dim strControlador As String

        My.Computer.Registry.SetValue("HKEY_CURRENT_USER\CREADORMVCPHP", "txtTabla", Me.txtTabla.Text)

        strModelo = crearModelo.generaModelo()
        strControlador = crearControlador.generaControlador()


        Me.DialogResult = System.Windows.Forms.DialogResult.OK
        Me.Close()
    End Sub

    Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
        Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.Close()
    End Sub

    Private Sub btnRuta_Click(sender As Object, e As EventArgs) Handles btnRuta.Click

        dlgRuta.ShowDialog()

        txtRuta.Text = dlgRuta.SelectedPath


    End Sub

    Private Sub frmCreaCatalogo_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        If Not My.Computer.Registry.GetValue("HKEY_CURRENT_USER\CREADORMVCPHP", "txtTabla", Nothing) Is Nothing Then

            Me.txtTabla.Text = My.Computer.Registry.GetValue("HKEY_CURRENT_USER\CREADORMVCPHP", "txtTabla", Nothing).ToString()

        End If
    End Sub
End Class

Saludos y espero que les sirva

Creando el texto para el modelo del catalogo en PHP en Visual Basic 2022

Hasta ahora ya nos pudimos conectar a la base de datos, hicimos consultas SQL a través de la conexión creada hicimos r creamos funciones para facilitar la programación, ahora nos toca simplemente maniobrar para crear todo el texto completo.

Como algo nuevo aprendido en este código es que no se pueden usar las comillas ” como escape por ejemplo \” en su lugar simplemente pones dos veces la doble comilla ejemplo “”

También el salto de linea que en gambas3 era gb.CrLf en Visual Basic 2022 es vbCrLf

Bien sin mas reparos les dejo como quedo finalmente el código para crear el código del modelo en PHP

'IMPORTAMOS LAS LIBRERIAS NECESARIAS PARA LA CONEXIÓN A MYSQL/MARIADB
Imports MySqlConnector.MySqlConnection

'EMPIEZA EL MODULO
Module crearModelo

    ' CON PUBLIC SUB CREAMOS PROCEDIMIENTOS
    Public Function generaModelo() As String

        ' VARIABLES PARA LA CONEXIÓN
        Dim strServidor As String
        Dim strBaseDeDatos As String
        Dim strUsuario As String
        Dim strContra As String

        'Variables de uso
        Dim strCampos As String
        Dim strCamposNoLLave As String
        Dim strLLavePrimaria As String
        Dim strCamposValue As String
        Dim strBindingInsert As String
        Dim strBindingUpdate As String
        Dim strCamposUpdate As String
        Dim strModelo As String

        'OBTENEMOS LOS DATOS DE CONFIGURACIÖN DEL REGISTRO DE WINDOWS PREVIAMENTE GUARDADAS
        If Not My.Computer.Registry.GetValue("HKEY_CURRENT_USER\CREADORMVCPHP", "servidor", Nothing) Is Nothing Then
            strServidor = My.Computer.Registry.GetValue("HKEY_CURRENT_USER\CREADORMVCPHP", "servidor", Nothing).ToString()
            strBaseDeDatos = My.Computer.Registry.GetValue("HKEY_CURRENT_USER\CREADORMVCPHP", "baseDeDatos", Nothing).ToString()
            strUsuario = My.Computer.Registry.GetValue("HKEY_CURRENT_USER\CREADORMVCPHP", "usuario", Nothing).ToString()
            strContra = My.Computer.Registry.GetValue("HKEY_CURRENT_USER\CREADORMVCPHP", "contra", Nothing).ToString()
        Else

            MsgBox("No se han capturado la conexión a la base de datos")
            Exit Function


        End If


        ' METEMOS LA CADENA DE CONEXIÓN EN UNA VARIABLE
        Dim cadenaConexion = "Server=" & strServidor & ";User ID=" & strUsuario & ";Password=" & strContra & ";Database=" & strBaseDeDatos

        ' CREAMOS LA CONEXIÓN CON LA CADENA DE CONEXIÓN
        Dim connection = New MySqlConnector.MySqlConnection(cadenaConexion)

        Try

            ' SI SE ABRE LA CONEXIÓN MANDAMOS MENSAJE
            connection.Open()



            Dim comando = New MySqlConnector.MySqlCommand("SHOW KEYS FROM  " & frmCreaCatalogo.txtTabla.Text & " WHERE Key_name = 'PRIMARY'", connection)

            Dim resultado = comando.ExecuteReader

            resultado.Read()


            'ASIGNAMOS EL CAMPO LLAVE

            strLLavePrimaria = resultado.GetString("Column_name")


            'OBTENEMOS LOS CAMPOS DE LA TABLA
            connection.Close()
            connection.Open()
            comando = Nothing
            comando = New MySqlConnector.MySqlCommand("describe  " & frmCreaCatalogo.txtTabla.Text & "", connection)
            resultado = Nothing
            resultado = comando.ExecuteReader



            Dim contador As Integer
            contador = 0


            While (resultado.Read)


                ' CAMPOS PARA EL Select
                If contador = 0 Then
                    strCampos = resultado.GetString("Field") & vbCrLf
                Else
                    strCampos = strCampos & "," & resultado("Field") & vbCrLf
                End If

                'CAMPOS PARA EL INSERT

                If resultado("Key") <> "PRI" Then
                    If contador = 1 Then
                        strCamposNoLLave = resultado("Field") & vbCrLf
                    Else
                        strCamposNoLLave = strCamposNoLLave & "," & resultado("Field") & vbCrLf
                    End If

                End If

                ' CAMPOS PARA EL VALUE

                If resultado("Key") <> "PRI" Then
                    If contador = 1 Then
                        strCamposValue = ":" & resultado("Field") & vbCrLf
                    Else
                        strCamposValue = strCamposValue & "," & ":" & resultado("Field") & vbCrLf
                    End If
                End If

                If resultado("Key") & vbCrLf <> "PRI" Then
                    strBindingInsert = strBindingInsert & "     $stmt -> bindParam("":" & resultado("Field") & """, $datos[""nuevo" & UCase(Mid$(resultado("Field"), 1, 1)) & Mid$(resultado("Field"), 2, 100) & """], PDO::PARAM_STR);" & vbCrLf
                End If

                ' CAMPOS UPDATE
                If resultado("Key") <> "PRI" Then

                    If contador = 1 Then

                        strCamposUpdate = strCamposUpdate & resultado("Field") & "= :" & resultado("Field")

                    Else

                        strCamposUpdate = strCamposUpdate & "," & resultado("Field") & "= :" & resultado("Field")

                    End If

                End If

                strBindingUpdate = strBindingUpdate & "     $stmt -> bindParam("":" & resultado("Field") & """, $datos[""editar" & utilerias.strPrimeraMayuscula(resultado("Field")) & """], PDO::PARAM_STR);" & vbCrLf

                contador = contador + 1



            End While


            strModelo = ""
            strModelo &= "<?php" & vbCrLf
            strModelo &= "require_once ""conexion.php"";" & vbCrLf
            strModelo &= "" & "" & vbCrLf



            strModelo &= "" & "Class Modelo" & UCase(Mid$(frmCreaCatalogo.txtTabla.Text, 1, 1)) & Mid$(frmCreaCatalogo.txtTabla.Text, 2, 25) & " {" & vbCrLf
            strModelo &= "" & "   /* =============================================" & vbCrLf
            strModelo &= "" & "     MOSTRAR " & UCase(frmCreaCatalogo.txtTabla.Text) & vbCrLf
            strModelo &= "" & "      ============================================= */" & vbCrLf
            strModelo &= "" & "" & vbCrLf
            strModelo &= "" & "    Static Public Function mdlMostrar($tabla, $item, $valor) {" & vbCrLf
            strModelo &= "" & "" & vbCrLf
            strModelo &= "" & "       If ($item != Null) {" & vbCrLf
            strModelo &= "" & "" & vbCrLf
            strModelo &= "" & "           $stmt = Conexion:: conectar() -> prepare( ""Select " & strCampos

            strModelo &= "" & "           From " & frmCreaCatalogo.txtTabla.Text & " a WHERE $item =$item"");" & vbCrLf
            strModelo &= "" & "" & vbCrLf


            strModelo &= "" & "           $stmt -> bindParam( "":"" .$item, $valor, PDO::PARAM_STR);" & vbCrLf
            strModelo &= "" & "" & vbCrLf
            strModelo &= "" & "           Try {" & vbCrLf
            strModelo &= "" & "               $stmt -> execute();" & vbCrLf
            strModelo &= "" & "" & vbCrLf
            strModelo &= "" & "                Return $stmt -> fetch();" & vbCrLf
            strModelo &= "" & "           } Catch (PDOException $e) {" & vbCrLf
            strModelo &= "" & "" & vbCrLf
            strModelo &= "" & "               $arr = $stmt -> errorInfo();" & vbCrLf
            strModelo &= "" & "                $arr[3] = ""Error"";" & vbCrLf
            strModelo &= "" & "" & vbCrLf
            strModelo &= "" & "               If ($e -> getMessage() == 23000) {" & vbCrLf
            strModelo &= "" & "                   $mensaje = "" El registro esta duplicado, Favor de checar el numero de nomina "";" & vbCrLf
            strModelo &= "" & "                   Return $mensaje;" & vbCrLf
            strModelo &= "" & "               } Else {" & vbCrLf
            strModelo &= "" & "                  Return $arr[2];" & vbCrLf
            strModelo &= "" & "              }" & vbCrLf
            strModelo &= "" & "           }" & vbCrLf
            strModelo &= "" & "           " & vbCrLf
            strModelo &= "" & "           " & vbCrLf
            strModelo &= "" & "       } Else {" & vbCrLf
            strModelo &= "" & "" & vbCrLf
            strModelo &= "" & "           $stmt = Conexion:: conectar() -> prepare(""Select * """ & vbCrLf
            strModelo &= "" & "" & vbCrLf
            strModelo &= "" & "           " & vbCrLf
            strModelo &= "" & "" & vbCrLf
            strModelo &= "" & "           From " & frmCreaCatalogo.txtTabla.Text & " a ""); """ & vbCrLf
            strModelo &= "" & "" & vbCrLf
            strModelo &= "" & "           $stmt -> execute();" & vbCrLf
            strModelo &= "" & "" & vbCrLf
            strModelo &= "" & "           Return $stmt -> fetchAll();" & vbCrLf
            strModelo &= "" & "       }" & vbCrLf
            strModelo &= "" & "" & vbCrLf
            strModelo &= "" & "" & vbCrLf
            strModelo &= "" & "       $stmt -> close();" & vbCrLf
            strModelo &= "" & "" & vbCrLf
            strModelo &= "" & "        $stmt = Null;" & vbCrLf
            strModelo &= "" & "   }" & vbCrLf
            strModelo &= "" & "" & vbCrLf

            ' REGISTRO

            strModelo &= "" & "   /* ==================================================================" & vbCrLf
            strModelo &= "" & "     REGISTRO" & vbCrLf
            strModelo &= "" & "    ==================================================================== */" & vbCrLf
            strModelo &= "" & "" & vbCrLf
            strModelo &= "" & "   Static Public Function mdlIngresar($tabla, $datos) {" & vbCrLf
            strModelo &= "" & "" & vbCrLf
            strModelo &= "" & "      $stmt = Conexion:: conectar() -> prepare(""INSERT INTO " & frmCreaCatalogo.txtTabla.Text & "(" & strCamposNoLLave & "" & vbCrLf
            strModelo &= "" & "        " & vbCrLf
            strModelo &= "" & "                                                                       )" & vbCrLf
            strModelo &= "" & "                                                                       VALUES(" & strCamposValue & ")" & vbCrLf
            strModelo &= "" & "                          " & vbCrLf
            strModelo &= "" & "                                                                              ""); " & vbCrLf
            strModelo &= "" & ""

            strModelo &= "" & strBindingInsert & vbCrLf

            strModelo &= "" & "" & vbCrLf
            strModelo &= "" & "" & vbCrLf
            strModelo &= "" & "       If ($stmt -> execute()) {" & vbCrLf
            strModelo &= "" & "" & vbCrLf
            strModelo &= "" & "           Return ""ok"";" & vbCrLf
            strModelo &= "" & "       } Else {" & vbCrLf
            strModelo &= "" & "" & vbCrLf
            strModelo &= "" & "           $arr = $stmt -> errorInfo();" & vbCrLf
            strModelo &= "" & "           $arr[3] = "" Error "";" & vbCrLf
            strModelo &= "" & "          Return $arr[2];" & vbCrLf
            strModelo &= "" & "      }" & vbCrLf

            strModelo &= "" & "      $stmt -> close();" & vbCrLf

            strModelo &= "" & "      $stmt = Null;" & vbCrLf
            strModelo &= "" & "  }" & vbCrLf



            'EDITAR ACTUALIZAR
            strModelo &= "" & "  /* ==================================================================" & vbCrLf
            strModelo &= "" & "   EDITAR " & vbCrLf
            strModelo &= "" & "     ================================================================== */" & vbCrLf
            strModelo &= "" & "" & vbCrLf
            strModelo &= "" & "   Static Public Function mdlEditar($tabla, $datos) {" & vbCrLf
            strModelo &= "" & "" & vbCrLf
            strModelo &= "" & "       $stmt = Conexion:: conectar() -> prepare("" UPDATE $tabla Set " & strCamposUpdate & "" & vbCrLf
            strModelo &= "" & ""
            strModelo &= "" & "                                                                   WHERE id =" & strLLavePrimaria & "  ""); " & vbCrLf
            strModelo &= "" & "" & vbCrLf
            strModelo &= "" & strBindingUpdate
            strModelo &= "" & "" & vbCrLf
            strModelo &= "" & "" & vbCrLf
            strModelo &= "" & "       If ($stmt -> execute()) {" & vbCrLf
            strModelo &= "" & "" & vbCrLf
            strModelo &= "" & "           Return ""ok"";" & vbCrLf
            strModelo &= "" & "     } Else {" & vbCrLf
            strModelo &= "" & ""
            strModelo &= "" & "          Return ""Error"";" & vbCrLf
            strModelo &= "" & "      }" & vbCrLf
            strModelo &= "" & ""
            strModelo &= "" & "     $stmt -> close();" & vbCrLf
            strModelo &= "" & "" & vbCrLf
            strModelo &= "" & "      $stmt = Null;" & vbCrLf
            strModelo &= "" & "   }" & vbCrLf
            strModelo &= "" & "   " & vbCrLf
            strModelo &= "" & " " & vbCrLf & vbCrLf
            strModelo &= "" & "  /* ===================================================================" & vbCrLf
            strModelo &= "" & "     BORRAR USUARIO" & vbCrLf
            strModelo &= "" & "     =================================================================== */" & vbCrLf
            strModelo &= "" & "" & vbCrLf
            strModelo &= "" & "  Static Public Function mdlBorrar($tabla, $datos) {" & vbCrLf

            strModelo &= "" & "       $stmt = Conexion:: conectar() -> prepare( "" DELETE From " & frmCreaCatalogo.txtTabla.Text & " WHERE id =:id"");" & vbCrLf
            strModelo &= "" & "" & vbCrLf
            strModelo &= "" & "       $stmt -> bindParam("":id"", $datos, PDO::PARAM_INT);" & vbCrLf
            strModelo &= "" & "" & vbCrLf
            strModelo &= "" & "      If ($stmt -> execute()) {" & vbCrLf
            strModelo &= "" & "" & vbCrLf
            strModelo &= "" & "Return ""ok"";" & vbCrLf
            strModelo &= "" & "      } Else {" & vbCrLf

            strModelo &= "" & "          Return ""Error"";" & vbCrLf
            strModelo &= "" & "      }" & vbCrLf

            strModelo &= "" & "        $stmt -> close();" & vbCrLf

            strModelo &= "" & "       $stmt = Null;" & vbCrLf
            strModelo &= "" & "    }" & vbCrLf
            strModelo &= "" & "" & vbCrLf
            strModelo &= "" & "}" & vbCrLf


            generaModelo = strModelo
        Catch ex As Exception
            ' SI NO SE ABRE LA CONEXIÓN MANDAMOS MENSAJE DE ERROR
            MsgBox("ERROR " & ex.Message)

            Exit Function
        End Try

    End Function

End Module

Funciones UCase y Mid$ y concatenado de Strings en Visual Basic 2022

De aquí en adelante trabajaremos manejando texto para crear el código del modelo vista controlador, así que la primera función que necesitamos crear es la de convertir la primera letra una cadena “Palabra” en mayúscula, para ello usaremos las funciones UCase, la cual sirve para convertir todo el texto le le mandemos en mayuscula por ejemplo si ponemos UCase(“kakaroto”) el resultado sera “KAKAROTO”. En cambio la función Mid$ nos servirá para obtener una parte del texto por ejemplo si ponemos mid$(“kakaroto”,1,1) el resultado sera “k” o si ponen mid$(“kakaroto”,1,2) el resultado sera “ka”.

Para el concatenado de dos variables con texto simplemente se contatena con amperson &

Por ejemplo en la variable strTexto1 tiene asignado el siguiente texto “Texto de prueba” y la variable strTexto2 tiene asignado el texto “17 de agosto de 2022” si concatenamos strTexto1 & strTexto2 el resultado sera “Texto de prueba 17 de agosto de 2022”

Entonces para solo ponerle la primera letra mayúscula a la cadena “kakaroto” seria de la siguiente forma UCase(Mid$(“kakaroto”, 1, 1)) & Mid$(“kakaroto”, 2, 100) y el resultado seria “Kakaroto”

El código fuente para usar la función seria la siguiente

Module utilerias


    Public Function strPrimeraMayuscula(strCadena As String) As String

        Return UCase(Mid$(strCadena, 1, 1)) & Mid$(strCadena, 2, 100)

    End Function


End Module

Página 18 de 139

Creado con WordPress & Tema de Anders Norén