Public feed
#532709
class Database { /* * Database Class * To be used as follows * $dbmod = Database::getConn(); * $query = "select * from *"; * $query = mysql_query($query); * */ private $_conn; private function __construct() { global $db_config; $this->_conn = mysql_connect($db_config['host'], $db_config['user'], $db_config['pass']); if(!is_resource($this->_conn)) { die('Connection Error <!-- Unable to connect to the database' . mysql_error() . '-->'); } mysql_select_db($db_config['db']) or die('DB Error <!-- Cannot select database -->'); } public function __destruct() { if (is_resource($this->_conn)) { @mysql_close($this->_conn); } } static public function getConn() { static $_DB; if (!isset($_DB)) { $_DB = new Database(); } return $_DB; } }