Should throw exception on error.

Explicit check is unnecessary.
PDO::query() too should throw exceptions.
Remove misleading foreach.

It's not truly a loop, but just running fetch.