<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
// +----------------------------------------------------------------------+
// | Singleton Database Class                                             |
// | File name : database.php                                             |
// | PHP version >= 5.2                                                   |
// +----------------------------------------------------------------------+
// | Author: BINU CHANDRAN.E<binu.chandran@armiasystems.com>              |
// +----------------------------------------------------------------------+
// | Copyrights Armia Systems � 2010                                      |
// | All rights reserved                                                  |
// +----------------------------------------------------------------------+
// | This script may not be distributed, sold, given away for free to     |
// | third party, or used as a part of any internet services such as      |
// | webdesign etc.                                                       |
// +----------------------------------------------------------------------+

class BaseDatabase
{
	/**
    * Instance of this
	* @var instance
    **/
    private static $_instance = null;
    /**
    * Database connection
	* @var object
    **/
    private static $_connection = null;
	/**
	* constructor
	**/
    public function __construct()
    {
        
    }
	/**
	* Method to get instance of AbstractDatabase
	* @return object $_instance
	**/
    public static function getInstance()
    {
        if (self::$_instance == null) 
        {
            self::$_instance = new self;
        }
        return self::$_instance;
    }
	/**
	* Method to connect mysql server
	**/
    public function _connect()
    {
	
        if (!is_resource(self::$_connection)) 
        {
            self::$_connection = @mysqli_connect(MYSQL_HOST, MYSQL_USERNAME, MYSQL_PASSWORD)
             or die('Sorry, Unable to connect server');
            //        or die(mysqli_error());
            mysqli_select_db(self::$_connection,MYSQL_DB);
            
            mysqli_query(self::$_connection, "SET SESSION sql_mode ='' ");
        }
       return self::$_connection;
    }
	/**
	* Method to close mysql connection
	**/
    public function close()
    {
        if (is_resource(self::$_connection)) 
        {
            mysqli_close(self::$_connection);
        }
    }
    /**
	* Destructor
	**/
    public function __destruct()
    {
    	//Close sql connection
       // $this->close();
    }
}
?>