26 function __construct(Logger $logger)
28 parent::__construct($logger);
36 public function prepare($statementName, $sqlStatement)
38 if (array_key_exists($statementName, $this->preparedStatements)) {
39 if ($this->preparedStatements[$statementName] !== $sqlStatement) {
40 throw new \Exception(
"Existing Statement mismatch: $statementName");
44 $startTime = microtime($get_as_float =
true);
45 $res = $this->dbDriver->prepare($statementName, $sqlStatement);
46 $this->cumulatedTime[$statementName] = microtime($get_as_float =
true) - $startTime;
47 $this->queryCount[$statementName] = 0;
48 $this->logger->addDebug(
"prepare '$statementName' took " . sprintf(
"%0.3fms", 1000 * $this->cumulatedTime[$statementName]));
49 $this->
checkResult($res,
"$sqlStatement -- $statementName");
50 $this->preparedStatements[$statementName] = $sqlStatement;
59 public function execute($statementName, $params = array())
61 if (! array_key_exists($statementName, $this->preparedStatements)) {
62 throw new \Exception(
"Unknown Statement");
64 $startTime = microtime($get_as_float =
true);
65 $res = $this->dbDriver->execute($statementName, $params);
66 $execTime = microtime($get_as_float =
true) - $startTime;
68 $this->
checkResult($res,
"$statementName: " . $this->preparedStatements[$statementName] .
' -- -- ' . print_r($params,
true));
prepare($statementName, $sqlStatement)
execute($statementName, $params=array())
checkResult($result, $sqlStatement="")
Check the result for unexpected errors. If found, treat them as fatal.
collectStatistics($statementName, $execTime)