php69

Curso de PHP馃悩 y MySql馃惉 [69.- Conexi贸n a MySQL y SQLite v铆a PDO]

En este tutorial nos vamos a conectar a mysql y sqlite con casi las mismas lineas de codigo y esto es gracias a PDO (PHP Data Objects) la cual es una forma de conectarnos a las diferentes bases de datos como:

  • MySQL
  • PostgreSQL
  • Oracle
  • SQLite
  • Firebase

Codigo: https://github.com/programadornovato/php/commit/16bed2b56961298d0ec3235c9d0aad01c8f970b7

<!doctype html>
<html lang="en">

<head>
    <title>PDO</title>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
</head>

<body>
    <?php
    
    try {
        //$conexion=new PDO("mysql:host=localhost;database=empresa","eugenio","123456");
        $conexion=new PDO("sqlite:miDB.sqlite");
    } catch (\Throwable $th) {
        die("Error de conexion ".$th->getMessage());
    }
    finally{
        $conexion=null;
    }
    echo "Conexion existosa";
    ?>
    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>

</html>

馃敆Acceder a sqlite desde VSCode: https://marketplace.visualstudio.com/items?itemName=alexcvzz.vscode-sqlite
馃敆Pagina SQLite: https://www.sqlite.org/index.html

馃帵 Esta lista de reproducci贸n: https://www.youtube.com/playlist?list=PLCTD_CpMeEKS2Dvb-WNrAuDAXObB8GzJ0

Codigos en gdrive: https://drive.google.com/file/d/1tQwYvfL2jiUFc6beTWkOkGmXkq5zzFw2/view?usp=sharing
Gracias por apoyar este canal: https://www.patreon.com/programadornovato?fan_landing=true

馃敆 Facebook: https://facebook.com/ProgramadorNovatoOficial
馃敆 Twitter: https://twitter.com/programadornova
馃敆 Linkedin: https://www.linkedin.com/in/programadornovato/
馃敆 Instagram: https://www.instagram.com/programadornovato/

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

En Programador Novato vivimos de los anuncios, hemos detectado que est谩 utilizando extensiones para bloquear anuncios. Ayudanos deshabilitando tu bloqueador de anuncios. :)