Add a PDO exception if PDO has a problem

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1408 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2014-06-04 12:17:22 +00:00
parent 65b83208f7
commit 2e8dd883d2

View File

@@ -76,8 +76,15 @@ class dblayer extends PDO
function __construct ($dsn, $username=null, $password=null,
$driver_options=null)
{
$this->db = new PDO ($dsn, $username, $password, $driver_options);
$this->db->setAttribute (PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
try
{
$this->db = new PDO ($dsn, $username, $password, $driver_options);
$this->db->setAttribute (PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch (Exception $e)
{
throw new Exception ("PDO error : ".$e->getMessage());
}
}
/** Create a new entry in the table. Datas must be an indexed array