9 namespace Fossology\Lib\Db;
15 function __construct(Logger $logger)
17 parent::__construct($logger);
25 public function prepare($statementName, $sqlStatement)
27 if (array_key_exists($statementName, $this->preparedStatements)) {
28 if ($this->preparedStatements[$statementName] !== $sqlStatement) {
29 throw new \Exception(
"Existing Statement mismatch: $statementName");
33 $startTime = microtime($get_as_float =
true);
34 $res = $this->dbDriver->prepare($statementName, $sqlStatement);
35 $this->cumulatedTime[$statementName] = microtime($get_as_float =
true) - $startTime;
36 $this->queryCount[$statementName] = 0;
37 $this->logger->debug(
"prepare '$statementName' took " . sprintf(
"%0.3fms", 1000 * $this->cumulatedTime[$statementName]));
38 $this->
checkResult($res,
"$sqlStatement -- $statementName");
39 $this->preparedStatements[$statementName] = $sqlStatement;
48 public function execute($statementName, $params = array())
50 if (! array_key_exists($statementName, $this->preparedStatements)) {
51 throw new \Exception(
"Unknown Statement");
53 $startTime = microtime($get_as_float =
true);
54 $res = $this->dbDriver->execute($statementName, $params);
55 $execTime = microtime($get_as_float =
true) - $startTime;
57 $this->
checkResult($res,
"$statementName: " . $this->preparedStatements[$statementName] .
' -- -- ' . print_r($params,
true));
checkResult($result, $sqlStatement="")
Check the result for unexpected errors. If found, treat them as fatal.
collectStatistics($statementName, $execTime)
prepare($statementName, $sqlStatement)
execute($statementName, $params=array())