PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, PDO::ATTR_EMULATE_PREPARES => false, ]); return $p; } catch (PDOException $e) { // In a real app, you'd log this error and show a generic message throw new PDOException($e->getMessage(), (int)$e->getCode()); } }