9951 explained code solutions for 126 technologies


php-pdoEnable exceptions in PHP PDO


$pdo = new PDO('mysql:host=localhost;dbname=test', 'usr', 'pwd');
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);ctrl + c
$pdo

PDO connection object

new PDO

create new PDO connection

setAttribute

sets configuration option for PDO

ATTR_ERRMODE

error handing mode settings

ERRMODE_EXCEPTION

will throw PDOException exceptions on errors