Invalid argument supplied for foreach() is the typical error message when you provide a foreach loop with something other than an array, or Traversable instance/implementation. For example null or a boolean.
The docs help: PDO::query() returns a PDOStatement object, or FALSE on failure. (http://php.net/manual/pdo.query.php)
You should use PDO::errorInfo() to get some more hints (Docs: http://php.net/manual/pdo.errorinfo.php), for your code:
$pdo->errorInfo();
This sounds weird actually, since this should not be a question of data. Maybe it's a matter of permissions. I first thought maybe terminal is a reserved word, but couldn't find any evidence.
Otherwise, you might be better of if you set your PDO error mode to exception. Then you get an exception whenever something goes wrong. The default is silent (more info here http://php.net/manual/pdo.error-handling.php)
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
This is probably more handy in development, than in production.