PdoDataSource::__construct PHP Method

__construct() public method

The first argument can either be a string DSN or an array which contains the construction arguments.
public __construct ( mixed $dsn, string $username = '', string $password = '', array $driver_options = [] )
$dsn mixed String DSN or array of arguments (dsn, username, password)
$username string
$password string
$driver_options array
    function __construct($dsn, $username = '', $password = '', $driver_options = array())
    {
        if (is_array($dsn)) {
            $args = $dsn;
            if (isset($args[0])) {
                $dsn = $args[0];
            }
            if (isset($args[1])) {
                $username = $args[1];
            }
            if (isset($args[2])) {
                $password = $args[2];
            }
            if (isset($args[3])) {
                $driver_options = $args[3];
            }
        }
        try {
            parent::__construct($dsn, $username, $password, $driver_options);
            parent::setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        } catch (PDOException $exception) {
            throw new DataSourceCouldNotConnectException($exception->getMessage(), get_defined_vars());
        }
        $this->cachePrefix = self::CACHE_PREFIX . $dsn . '::*::';
        $this->provider = $this->instantiateProvider();
    }