$PDO_db = new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME.';charset=UTF-8' , DB_USER, DB_PWD);
$sth = $PDO_db->prepare($insert);
$arrPar = array(':nome' => $nome);
$r = $sth->execute($arrPar);
var_dump($arrPar);
print_r($PDO_db->errorInfo());
var_dump($r);
exit();
Supppose that the $insert statemet contains a SQL error, with the code above I've noticed the following :
-
Code A
print_r($PDO_db->errorInfo());
will output anyways:
Array ( [0] => 00000 [1] => [2] => )
but var_dump($s) is false
-
If in the insert statement I have some
placemark
e.g.:name
"Insert into mytable (name) VALUE(:name);"
And then in the
$arrPar = array(':name' => $value)
with$value=NULL
print_r($PDO_db->errorInfo());
will output again:
Array ( [0] => 00000 [1] => [2] => )
but var_dump($s) is false
So I'm wondering to know what's the correct way to debug MySQL statements with PDO if the method errorInfo, which is supposed to give me a error description, silently quiets errors?
PDO::errorInfo()
returns an array of error information"