Metziop

Untitled

Jun 16th, 2023
645
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.65 KB | None | 0 0
  1. <?php
  2.  
  3. class Database
  4. {
  5.     private $host = "localhost:3306";
  6.     private $db_name = "siiiecam_db_Agenda_Folio";
  7.     private $username = "siiiecam_admin";
  8.     private $password = "*********";
  9.  
  10.     private $conn;
  11.  
  12.     //metodo de conexion
  13.     public function getConnection(){
  14.         $this->conn = null;
  15.         try {
  16.             $this->conn = new PDO("mysql:host=".$this->host.";dbname=".$this->db_name,$this->username,$this->password);
  17.             $this->conn->exec("set names utf8");
  18.         } catch (PDOException $exception) {
  19.             echo "Error de conexion: ".$exception->getMessage();
  20.         }
  21.         return $this->conn;
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment