Hi.
I am sure there is an easy answer to this, but I do not know it and have
not found the answer anywhere. I want to be able to dynamically set my
database from an array of options:
$database = array(
array(
"type" => "mssql",
"name" => "database1",
"hostName" => "hostname1",
"username" => "username1",
"password" => "password1",
"databaseName" => "database1"),
array(
"type" => "mssql",
"name" => "database2",
"hostName" => "hostname2",
"username" => "username2",
"password" => "password2",
"databaseName" => "database2"),
);
// default database
$id = 0;
I am trying to use this line using PEAR DB, but the variable does not
get interpreted so it never works (the line wraps; it is not the line
wrapping):
$dsn =
"{$servers[$id]["type"]}://{$servers[$id]["username"]}:{$servers[$id]["password"]}@{$servers[$id]["hostName"]}/{$servers[$id]["databaseName"]}";
This works, so the problem is translating $id properly:
$dsn =
"{$servers[0]["type"]}://{$servers[0]["username"]}:{$servers[0]["password"]}@{$servers[0]["hostName"]}/{$servers[0]["databaseName"]}";
I would appreciate any help with this.
--
Regards,
John Ellingsworth
http://john.ellingsworth.org
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php