// there are three supported ways of handing errors
// 1. PDO::ERROR_SILENT ->PDO sets an error code
// 2. ERRMODE_WARNING -> set an error code and warning message
// 3. PDO::ERRMODE_EXCEPTION -> error and exception
// To set the error handling strategy, you can pass an associative array
// there are two ways to set the error modes
//to the PDO constructor like this:
$pdo = new PDO($dsn, $user, $password, [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]);
//Or you can use the setAttribute() method of the PDO instance:
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);