Q:

PDO throws exception with a warning

I have successfully written my OOP class that extends PDO and everything seems to work as expected! However I am confused that if wrong db user/pass combination or name is provided, it throws Exception which is good but if "db host" is incorrect or invalid, it throws a warning with exception, why is that?

[11-Dec-2013 14:37:01 UTC] PHP Warning:  PDO::__construct():
  php_network_getaddresses: getaddrinfo failed: Name or service not
  known in
  /home/sdrop/public_html/includes/modules/monetarysoft/ttbs.php on line
  15

A:

Moved to answer on request:
Its because you're still providing a valid host name but there's no service running on it.
The problem is the input is a string so almost all inputs for host name are valid ie: localhost or 127.0.0.1 or blah.blah.com etc etc so it can't flat out fail on the input.
It can only fail if there's no service running on the provided host which is why it warns you that there's no service running and then throws the exception.

