I'm using my localhost to work on my project, but sometimes i need to put the website online to show it for my clients. When i do this i need to change the pdo connection details the webhosting's connection details.
Is there any way in PHP to do it automatically? I mean that i create in various connections, and if PDO cant connect to the first, then tries an another.
$option1 = new PDO('mysql:host=host1;dbname=db1', 'user1', 'pw1');
$option2 = new PDO('mysql:host=host2;dbname=db2', 'user2', 'pw2');
$option3 = new PDO('mysql:host=host3;dbname=db3', 'user3', 'pw3');
I need a script which tries out each of the options, connects to the right database, and returns a simple $db object.