Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created December 13, 2018 18:07
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/da3200cbe168944a19fdfaaed8916b99 to your computer and use it in GitHub Desktop.
Save parzibyte/da3200cbe168944a19fdfaaed8916b99 to your computer and use it in GitHub Desktop.
<?php
function obtenerBaseDeDatos()
{
$host = "127.0.0.1";
$puerto = "27017";
$usuario = rawurlencode("parzibyte");
$pass = rawurlencode("hunter2");
$nombreBD = "agenda";
# Crea algo como mongodb://parzibyte:hunter2@127.0.0.1:27017/agenda
$cadenaConexion = sprintf("mongodb://%s:%s@%s:%s/%s", $usuario, $pass, $host, $puerto, $nombreBD);
$cliente = new MongoDB\Client($cadenaConexion);
return $cliente->selectDatabase($nombreBD);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment