protected function executeQuery($query, Connection $connection, array $params = [])
{
if ($query == null) {
throw new \DatabaseException("Query cannot be null");
}
$this->query_count++;
if ($this->timer) {
$timer_key = preg_replace('~\\s+~', ' ', trim($query . '|' . serialize($params)));
$this->timer->begin(['SQL', $timer_key]);
}
try {
if ($params) {
$value = $connection->executeQuery($query, $params);
} else {
// faster
$value = $connection->query($query);
}
} catch (\Exception $e) {
throw new \DatabaseException($e->getMessage() . "\n\n" . "QUERY: {$query} \n\n" . "PARAMS: " . print_r($params, true));
}
if ($this->timer) {
$this->timer->end(['SQL', $timer_key]);
}
return $value;
}