Created
October 2, 2013 03:02
-
-
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
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 | |
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