<?php
/*******************************************************************************
 *                    _ _ _ _
 *                   / _ _  /
 *            _ _   / /__/ /_ _   ____ _ _   _ _ _    __
 *           / _ ` /   _ _// _ ` / __// _ ` / _ \\ \ / /
 *          / _ _// /\ \  / _ _/ \_ \/ _ _// / \/ \ ` /
 *          \_ , /_/  \_\ \_ ,  /__ /\_ , /_/      \_/
 *
 *******************************************************************************
 *    Application:  eReserv
 *    Version:      6
 *    Author:       David Di Certo
 *    Website:      http://www.cogites.com
 *    Email:        contact@cogites.com
 *    Copyright:    2013 - David Di Certo
 *******************************************************************************
 *    == FR ==      La revente et la redistribution de l'application sont
 *                  strictement interdites.
 *
 *                  Vous êtes tenu d'avoir pris connaissance des
 *                  Conditions Générales de Vente disponibles sur Cogites.com
 *                  (y compris pour la version Free).
 *
 *    == EN ==      Resale and redistribution of the application are
 *                  Strictly prohibited.
 *
 *                  You are required to have read the Terms and Conditions
 *                  available on Cogites.com (including the Free version).
 *
 *******************************************************************************
*/


/**
 * DBConnector uses to manage a static DB Connection.
 *
 */

include_once("config/Settings.php");
		
class DBConnector
{
    /**
     * Database connection adapter instance
     *
     * @var PDO
     */
    static protected $_zendAdapter = null;
    
    /**
     * Constructor is private - no instantiating this class
     *
     */
    private function __construct()
    { }
    
    function __destruct() {
    	$_zendAdapter = null;
    }
    /**
     * Prevent cloning of this class
     *
     */
    private function __clone()
    { }
    
    static public function getZendDbConnection()
    {    
		if (self::$_zendAdapter==null) {
			self::$_zendAdapter = new Zend\Db\Adapter\Adapter(array(
				'driver' => DATABASE_DB_DRIVER, //Mysqli, Sqlsrv, Pdo_Sqlite, Pdo_Mysql, Pdo=OtherPdoDriver
				'hostname' => DATABASE_DB_HOSTNAME,
				'port' => DATABASE_DB_PORT,
				'database' => DATABASE_DB_DBNAME,
				'username' => DATABASE_DB_USER,
				'password' => DATABASE_DB_PASSWORD,
				'charset' => 'UTF8'
			));
		}
		return self::$_zendAdapter;
    }	
    
}