The right way to check LoggingStatement::errorCode() in an if statement?

When I call errorCode() on a query $result, I get 00000, which looks like a string and not an integer like I’d expect.

What would be a reliable way to put it into an if statement to see if there were no errors?

  • !$result->errorCode()
  • (int)$result->errorCode() !== 0
  • !empty($result->errorCode())
  • $result->errorCode() === '00000'

I would imagine casting it as integer should be fine in most cases?

Cake’s Table class explicitly uses $statement->errorCode() === '00000'. But what’s your context for this? Many of the functions you’d want to call would already be returning a boolean indication of success or failure, so this sort of explicit error code checking should be largely superfluous.