First of all, it is necessary to include in the PDO the mode of generating exceptions, for which a connection should specify the corresponding parameter:
$dsn = "mysql:host=$host;dbname=$db;charset=$charset"; $opt = array( PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, ); $pdo = new PDO($dsn, $user, $pass, $opt);
And secondly, make sure that PHP errors are visible to the developer. if an error occurs in PHP, then he will always report it. The task of the PHP user is to always see all messages about errors that occur in his scripts. Thus, he will be informed about the causes of a particular problem, without the need to contact other sites.
Well, make sure that the database has data that meets the query.
When sampling large amounts of data, you should avoid using the fetchall function, and you should loop through the rows one at a time through fetch.
On the pages shown to users of the site, you should avoid samples of large volumes of data in principle.