Commit 0698cba6 authored by Andreas Pohl's avatar Andreas Pohl

build a correct connection string for mirrored databases, too. In this case...

build a correct connection string for mirrored databases, too. In this case "host=ip1:port,ip2:port"
servername and dbname are optional but can also be used without host parameter
parent 2cdd579c
...@@ -45,6 +45,7 @@ class Driver extends AbstractSQLAnywhereDriver ...@@ -45,6 +45,7 @@ class Driver extends AbstractSQLAnywhereDriver
isset($params['port']) ? $params['port'] : null, isset($params['port']) ? $params['port'] : null,
isset($params['server']) ? $params['server'] : null, isset($params['server']) ? $params['server'] : null,
isset($params['dbname']) ? $params['dbname'] : null, isset($params['dbname']) ? $params['dbname'] : null,
isset($params['charset']) ? $params['charset'] : null,
$username, $username,
$password, $password,
$driverOptions $driverOptions
...@@ -73,27 +74,40 @@ class Driver extends AbstractSQLAnywhereDriver ...@@ -73,27 +74,40 @@ class Driver extends AbstractSQLAnywhereDriver
* SQL Anywhere allows multiple database server instances on the same host, * SQL Anywhere allows multiple database server instances on the same host,
* therefore specifying the server instance name to use is mandatory. * therefore specifying the server instance name to use is mandatory.
* @param string $dbname Name of the database on the server instance to connect to. * @param string $dbname Name of the database on the server instance to connect to.
* @param string $charset Charset
* @param string $username User name to use for connection authentication. * @param string $username User name to use for connection authentication.
* @param string $password Password to use for connection authentication. * @param string $password Password to use for connection authentication.
* @param array $driverOptions Additional parameters to use for the connection. * @param array $driverOptions Additional parameters to use for the connection.
* *
* @return string * @return string
*/ */
private function buildDsn($host, $port, $server, $dbname, $username = null, $password = null, array $driverOptions = array()) private function buildDsn($host, $port, $server, $dbname, $charset, $username = null, $password = null, array $driverOptions = array())
{ {
$host = $host ?: 'localhost'; // $host = $host ?: 'localhost';
$port = $port ?: 2638; // $port = $port ?: 2638;
if (! empty($server)) { if (!empty($host)) {
$server = ';ServerName=' . $server; $host = 'HOST=' . $host . (isset($port) ? (':' . $port) : '');
}
if (!empty($server)) {
$server = 'ServerName=' . $server;
}
if (!empty($dbname)) {
$dbname = 'DBN=' . $dbname;
}
if (!empty($charset)) {
$charset = 'CS=' . $charset;
} }
return return
'HOST=' . $host . ':' . $port . $host .
$server . ';'. $server .
';DBN=' . $dbname . ';'. $dbname .
';UID=' . $username . ';UID=' . $username .
';PWD=' . $password . ';PWD=' . $password .
';' . $charset .
';' . implode( ';' . implode(
';', ';',
array_map(function ($key, $value) { array_map(function ($key, $value) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment