- In separate config.php file:
- $db_people = new PDO('mysql:host=127.0.0.1;dbname=people;charset=UTF-8', 'root', 'pass');
- $db_animals = new PDO('mysql:host=127.0.0.1;dbname=animals;charset=UTF-8', 'root', 'pass');
- In other file named class_db.php
- class DB extends PDO
- {
- try
- {
- $db_people
- }
- catch (PDOException $e)
- {
- echo 'Connection failed: ' . $e->getMessage();
- }
- try
- {
- $db_animals
- }
- catch (PDOException $e)
- {
- echo 'Connection failed: ' . $e->getMessage();
- }
- }