yajra\Oci8\Connectors\OracleConnector::checkMultipleHostDsn PHP Method

checkMultipleHostDsn() protected method

Set DSN host from config.
protected checkMultipleHostDsn ( array $config ) : array
$config array
return array
    protected function checkMultipleHostDsn(array $config)
    {
        $host = is_array($config['host']) ? $config['host'] : explode(',', $config['host']);
        $count = count($host);
        if ($count > 1) {
            $address = "";
            for ($i = 0; $i < $count; $i++) {
                $address .= '(ADDRESS = (PROTOCOL = ' . $config["protocol"] . ')(HOST = ' . trim($host[$i]) . ')(PORT = ' . $config['port'] . '))';
            }
            // create a tns with multiple address connection
            $config['tns'] = "(DESCRIPTION = {$address} (LOAD_BALANCE = yes) (FAILOVER = on) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = {$config['database']})))";
        }
        return $config;
    }