Commit eff9d44a authored by Andreas Pohl's avatar Andreas Pohl Committed by Steve Müller

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 a2d21625
......@@ -45,6 +45,7 @@ class Driver extends AbstractSQLAnywhereDriver
isset($params['port']) ? $params['port'] : null,
isset($params['server']) ? $params['server'] : null,
isset($params['dbname']) ? $params['dbname'] : null,
isset($params['charset']) ? $params['charset'] : null,
$username,
$password,
$driverOptions
......@@ -73,27 +74,40 @@ class Driver extends AbstractSQLAnywhereDriver
* SQL Anywhere allows multiple database server instances on the same host,
* 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 $charset Charset
* @param string $username User name to use for connection authentication.
* @param string $password Password to use for connection authentication.
* @param array $driverOptions Additional parameters to use for the connection.
*
* @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';
$port = $port ?: 2638;
// $host = $host ?: 'localhost';
// $port = $port ?: 2638;
if (! empty($server)) {
$server = ';ServerName=' . $server;
if (!empty($host)) {
$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
'HOST=' . $host . ':' . $port .
$server .
';DBN=' . $dbname .
$host .
';'. $server .
';'. $dbname .
';UID=' . $username .
';PWD=' . $password .
';' . $charset .
';' . implode(
';',
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