Not able to select the database
and collection dynamically. Read all the solutions but not working for me. selectDB
function not working. It's working only with the static data.
I want to select the database from the configuration file and also select the collections dynamically.
$username='abcd';
$password='efgh';
$m = new MongoDB\Client("mongodb://abcd@127.0.0.1:28015/ijkl", array("username" => $username, "password" => $password));
$db = $m->ijkl;
but I want to have it like
$username='abcd';
$password='efgh';
$m = new MongoDB\Client("mongodb://abcd@127.0.0.1:28015/ijkl", array("username" => $username, "password" => $password));
$l1="ijkl";
$db = $m->$l1;
Expecting to work with dynamic database selection.