/** * @param null $params * @return bool * @throws null */ public function execute($params = null) { $preparedId = spl_object_hash($this); $boundParameters = $this->boundParameters; if (is_array($params)) { $boundParameters = array_merge($boundParameters, $params); } $trace = new TracedStatement($this->queryString, $boundParameters, $preparedId); $trace->start(); $ex = null; try { $result = parent::execute($params); } catch (PDOException $e) { $ex = $e; } if ($this->pdo->getAttribute(PDO::ATTR_ERRMODE) !== PDO::ERRMODE_EXCEPTION && $result === false) { $error = $this->errorInfo(); $ex = new PDOException($error[2], (int) $error[0]); } $trace->end($ex, $this->rowCount()); $this->pdo->addExecutedStatement($trace); if ($this->pdo->getAttribute(PDO::ATTR_ERRMODE) === PDO::ERRMODE_EXCEPTION && $ex !== null) { throw $ex; } return $result; }
/** * Profiles a call to a PDO method * * @param string $method * @param string $sql * @param array $args * @return mixed The result of the call */ protected function profileCall($method, $sql, array $args) { $trace = new TracedStatement($sql); $trace->start(); $ex = null; try { $result = call_user_func_array(array($this->pdo, $method), $args); } catch (PDOException $e) { $ex = $e; } if ($this->pdo->getAttribute(PDO::ATTR_ERRMODE) !== PDO::ERRMODE_EXCEPTION && $result === false) { $error = $this->pdo->errorInfo(); $ex = new PDOException($error[2], $error[0]); } $trace->end($ex); $this->addExecutedStatement($trace); if ($this->pdo->getAttribute(PDO::ATTR_ERRMODE) === PDO::ERRMODE_EXCEPTION && $ex !== null) { throw $ex; } return $result; }