/** * @brief Check the result for unexpected errors. If found, treat them as fatal. * @param resource $result command result object * @param string $sqlStatement SQL command (optional) */ protected function checkResult($result, $sqlStatement = "") { if ($result !== false) { return; } $lastError = ""; if ($this->dbDriver->isConnected()) { $lastError = $this->dbDriver->getLastError(); $this->logger->addCritical($lastError); if ($this->transactionDepth > 0) { $this->dbDriver->rollback(); } } else { $this->logger->addCritical("DB connection lost."); } $message = "error executing: {$sqlStatement}\n\n{$lastError}"; throw new Exception($message); }