1. In separate config.php file:
  2. $db_people = new PDO('mysql:host=127.0.0.1;dbname=people;charset=UTF-8', 'root', 'pass');
  3. $db_animals = new PDO('mysql:host=127.0.0.1;dbname=animals;charset=UTF-8', 'root', 'pass');
  4. In other file named class_db.php
  5. class DB extends PDO
  6. {
  7. try
  8. {
  9. $db_people
  10. }
  11. catch (PDOException $e)
  12. {
  13. echo 'Connection failed: ' . $e->getMessage();
  14. }
  15. try
  16. {
  17. $db_animals
  18. }
  19. catch (PDOException $e)
  20. {
  21. echo 'Connection failed: ' . $e->getMessage();
  22. }
  23. }