Skip to content

Instantly share code, notes, and snippets.

@maxisoft
Last active December 16, 2015 21:59
Show Gist options
  • Save maxisoft/5503521 to your computer and use it in GitHub Desktop.
Save maxisoft/5503521 to your computer and use it in GitHub Desktop.
<?php
final class Constantes
{
public static $db = null;
}
/**
* @return mysqli
*/
function md_bd_connection()
{
if (!Constantes::$db) {
Constantes::$db = new mysqli('host', 'username', 'passw', 'dbname'); //TODO
}
return Constantes::$db;
}
#test
var_dump(md_bd_connection());
$db = md_bd_connection();
$res = $db->query("SELECT 3 AS TEST");
var_dump($res->fetch_assoc());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment