For the following comment (source)
PHP does not report mysqli or PDO errors by default because that information is highly sensitive, displaying it to a user is a great way to learn how to inject malicious data.
MYSQLI_REPORT_ERROR tells it to turn on the errors and MYSQLI_REPORT_STRICT tells it to convert those errors into Exceptions. This will give you a full report of the error message, so never do this in production environments.
How would one check for foreign key constraint errors in production to notify the user that he or she is, for example, not able to delete a record until all associated records has been deleted?