Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created September 19, 2019 18:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/a467e721b8895fc2dc60882b62b991b2 to your computer and use it in GitHub Desktop.
Save parzibyte/a467e721b8895fc2dc60882b62b991b2 to your computer and use it in GitHub Desktop.
<?php
public function open($ruta_de_guardado, $nombre_de_sesion)
{
$pass = ""; // Contraseña del servidor MySQL
$usuario = "root"; // Usuario de MySQL
$nombre_base_de_datos = "test"; // El nombre de la base de datos (no el de la tabla)
$host = "localhost"; // El host, normalmente localhost pero puede ser una IP en algunos casos
try {
$this->base_de_datos = new PDO('mysql:host=' . $host
. ';dbname=' . $nombre_base_de_datos,
$usuario, $pass);
return true;
} catch (Exception $e) {
//TODO: Imprimir o guardar el mensaje en un log
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment