Exemple #1
0
 /**
  * @param Event $event
  * @param DbAdapterInterface $connection
  */
 public function afterQuery(Event $event, DbAdapterInterface $connection)
 {
     $this->_profiler->stopProfile();
     $sqlVariables = $connection->getSQLVariables() ?: [];
     foreach ($sqlVariables as $key => $value) {
         if ($key[0] !== ':') {
             unset($sqlVariables[$key]);
             $key = ':' . $key;
         }
         $sqlVariables[$key] = !is_array($value) ? $connection->escapeString((string) $value) : array_map(function ($v) use($connection) {
             return $connection->escapeString((string) $v);
             // important
         }, $value);
     }
     $statement = strtr($connection->getRealSQLStatement(), $sqlVariables);
     $time = $this->_profiler->getTotalElapsedSeconds() - $this->_previousTotalExecutionTime;
     $this->_previousTotalExecutionTime = $this->_profiler->getTotalElapsedSeconds();
     $this->_logger->log(sprintf('%s [Execution time: %.4f sec.]', $statement, round($time, 4)), $this->_priority);
 }