<?php
class Conexion2
{
    private static $connectionMap = array();

    public static function getConexion($nuevo='',$dsnName='default')
    {
    	
        $name = $dsnName;
        $o_MySQLConnection = isset(self::$connectionMap[$name]) ? self::$connectionMap[$name] : null;
        if($nuevo== 1) $o_MySQLConnection = null;
        if ($o_MySQLConnection === null)
        {

            $dsnInfo = isset(Constantes::$dsn[$name]) ? Constantes::$dsn[$name] : null;
            //$dsn = isset(self::$configuration['datasources'][$name]['connection']) ? self::$configuration['datasources'][$name]['connection'] : null;
            if ($dsnInfo === null) 
            {
                throw new Exception("No connection params set for " . $name);
            }
            try 
            {
                $o_MySQLConnection = new MySQLConnection();
                $o_MySQLConnection->connect($dsnInfo);
            }
            catch (SQLException $e) 
            {
                throw new Exception( $e );
            }
            self::$connectionMap[$name] = $o_MySQLConnection;
        }
        return $o_MySQLConnection;
    }
}
