Last active
December 16, 2015 21:59
-
-
Save maxisoft/5503521 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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