Skip to content

Instantly share code, notes, and snippets.

@evilnapsis
Created October 2, 2013 03:02
Show Gist options
  • Save evilnapsis/6788553 to your computer and use it in GitHub Desktop.
Save evilnapsis/6788553 to your computer and use it in GitHub Desktop.
Database.php es una clase sencilla para hacer las conexiones a la base de datos mysql
<?php
class Database {
public static $db;
public static $con;
function Database(){
$this->user="root";$this->pass="";$this->host="localhost";$this->ddbb="mydb";
}
function connect(){
$con = new mysqli($this->host,$this->user,$this->pass,$this->ddbb);
return $con;
}
public static function getCon(){
if(self::$con==null && self::$db==null){
self::$db = new Database();
self::$con = self::$db->connect();
}
return self::$con;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment