Skip to content

Instantly share code, notes, and snippets.

@bran921007
Created November 18, 2014 02:33
Show Gist options
  • Save bran921007/f20eb1915f6322deec72 to your computer and use it in GitHub Desktop.
Save bran921007/f20eb1915f6322deec72 to your computer and use it in GitHub Desktop.
clase conexion php
class Conexion{
private static $objCon = null;
private static $instancia = null;
public static function obtenerInstancia(){
if(self::$objCon == null){
self::$instancia = new Conexion();
self::$objCon = mysqli_connect("localhost","root","","{1:base_datos}");
}
return self::$objCon;
}
function __destruct(){
mysqli_close(conexion::obtenerInstancia());
}
}
$rs = conexion::obtenerInstancia();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment