php - Is there a need to test execute() result in PDO? -
i use following statement pdo mysql queries
$query = $db->prepare('mysql statement'); $result = $query->execute(array()) use $query->fetch or fetchcolumn (to check count(*)) fetch data.
my question - there need test whether $result true or not? in productive environment if mysql down error exist when declare new pdo.
under circumstances need test whether execute true or false?
it depends on pdo::attr_errmode
, explained in errors , error handling chapter.
if configure pdo throw exceptions (pdo::errmode_exception
) no, pdo automatically throw exception on error.
in other case (use default pdo connection options or explicitly set pdo::errmode_silent
or pdo::errmode_warning
) yes, need verify manually success of each individual operation.
it isn't useful pdo::errmode_exception
not default but, know, php has history of hiding helpful error messages misguided user-friendliness.
Comments
Post a Comment