devjed2020 / repo

0 stars 3 forks source link

Crear BD #1

Open EMMANUELRHZ opened 4 years ago

EMMANUELRHZ commented 4 years ago

se debe crear una base de datos para que se creen las tablas correspondientes y almacenar la información de los admin

EMMANUELRHZ commented 4 years ago

`<?php

class DB{ private $host; private $db; private $user; private $password; private $charset;

public function __construct(){
    $this->host     = 'localhost';
    $this->db       = 'iniciosesion';
    $this->user     = 'root';
    $this->password = "";
    $this->charset  = 'utf8mb4';
}

function connect(){

    try{

        $connection = "mysql:host=" . $this->host . ";dbname=" . $this->db . ";charset=" . $this->charset;
        $options = [
            PDO::ATTR_ERRMODE            => PDO::ERRMODE_EXCEPTION,
            PDO::ATTR_EMULATE_PREPARES   => false,
        ];
        $pdo = new PDO($connection, $this->user, $this->password, $options);

        return $pdo;

    }catch(PDOException $e){
        print_r('Error connection: ' . $e->getMessage());
    }   
}

}

?>

`

EMMANUELRHZ commented 4 years ago

se creo la conexion