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

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -