You don't quite understand the meaning of 404 error and confuse it with a 500 one.
A PDO error has nothing to do with page existence. It is a code error means site experiencing temporary problems. Thus, 500 has to be sent.
It is said that modern PHP versions have to take care of it, but I have some reports that it doesn't.
The only guaranteed way known to me is to use php-fpm, as sending 503 in case of error is one its core features.
Anyway, at least try to set display_errors = off in PHP settings (ini or perdir).
Then change your code to.
<?php
echo "Je me connecte a un module foireux et la page est introuvable.";
$pdo = new PDO("n'importe quoi !");
and properly configured PHP will respond with 500 automatically!
Yet if there is no page found - you indeed have to respond with 404.
<?php
$data = DB::getData("SELECT * FROM articles WHERE id=?", $_GET['id']);
if (!$data)
{
throw new http404();
}
where http404()
is a custom exception that have to be processed by a global exception handler. It have to send a 404 response. Just a
header("HTTP/1.0 404 Not Found");
exit;
would be enough for Google.