public function testPragmaIgnored()
 {
     $debug = new DebugStack();
     $data = new DatabaseDataCollector($debug);
     $debug->startQuery('PRAGMA test');
     $debug->stopQuery();
     $app = $this->getApp();
     $request = Request::create('/', 'GET');
     $response = $app->handle($request);
     $data->collect($request, $response);
     $this->assertEquals(0, $data->getQueryCount());
 }
Example #2
0
 public function logSql($sql, array $params = null)
 {
     parent::logSql($sql, $params);
     if (null !== $this->logger) {
         $this->log($sql . ' (' . str_replace("\n", '', var_export($params, true)) . ')');
     }
 }
Example #3
0
 /**
  * {@inheritdoc}
  */
 public function stopQuery()
 {
     parent::stopQuery();
     if (null !== $this->stopwatch) {
         $this->stopwatch->stop('doctrine');
     }
 }
 /**
  * {@inheritdoc}
  */
 public function startQuery($sql, array $params = null, array $types = null)
 {
     parent::startQuery($sql, $params, $types);
     if (null !== $this->logger) {
         $this->log($sql . ' (' . json_encode($params) . ')');
     }
 }
Example #5
0
 /**
  * {@inheritdoc}
  */
 public function invoke(MethodInvocation $invocation)
 {
     $object = $invocation->getThis();
     $method = $invocation->getMethod();
     $write = ['onPut', 'onDelete', 'onPost'];
     $connectionParams = in_array($method->name, $write) ? $this->masterDb : $this->slaveDb;
     $pagerAnnotation = $this->reader->getMethodAnnotation($method, 'BEAR\\Sunday\\Annotation\\DbPager');
     $db = $this->getDb($pagerAnnotation, $connectionParams);
     /* @var $db \BEAR\Package\Module\Database\Dbal\PagerConnection */
     if ($this->sqlLogger instanceof SQLLogger) {
         $db->getConfiguration()->setSQLLogger($this->sqlLogger);
     }
     $object->setDb($db);
     $result = $invocation->proceed();
     if ($this->sqlLogger instanceof DebugStack) {
         $this->sqlLogger->stopQuery();
         $object->headers['x-sql'] = [$this->sqlLogger->queries];
     } elseif ($this->sqlLogger instanceof SQLLogger) {
         $this->sqlLogger->stopQuery();
     }
     if (!$pagerAnnotation) {
         return $result;
     }
     $pagerData = $db->getPager();
     if ($pagerData) {
         $object->headers['pager'] = $pagerData;
     }
     return $result;
 }
Example #6
0
 /**
  * {@inheritdoc}
  */
 public function startQuery($sql, array $params = null, array $types = null)
 {
     parent::startQuery($sql, $params, $types);
     if (null !== $this->logger) {
         $this->log($sql . ' (' . str_replace("\n", '', var_export($params, true)) . ')');
     }
 }
 public function testGetQueryTime()
 {
     $start = microtime(true);
     $this->assertEquals(0, $this->collector->getQueryTime());
     $this->logger->startQuery('some sql');
     $this->logger->stopQuery();
     $time = microtime(true) - $start;
     $time1 = $this->collector->getQueryTime();
     $this->assertGreaterThan(0, $time1);
     $this->assertLessThan($time, $time1);
     $this->logger->startQuery('some more sql');
     $this->logger->stopQuery();
     $time = microtime(true) - $start;
     $time2 = $this->collector->getQueryTime();
     $this->assertGreaterThan($time1, $time2);
     $this->assertLessThan($time, $time1);
 }
Example #8
0
    public function stopQuery()
    {
        parent::stopQuery();

        $q = $this->queries[$this->currentQuery];
        $message = "Executed Query:  " . print_r($q, true);
        $this->logger->info($message);
    }
 /**
  * {@inheritdoc}
  */
 public function stopQuery()
 {
     parent::stopQuery();
     if (null !== $this->stopwatch) {
         $this->stopwatch->stop('doctrine');
     }
     if ($this->enabled) {
         $this->queries[$this->currentQuery]['callstack'] = $this->callstack;
     }
 }
Example #10
0
 /**
  * stopQuery
  * 
  * Perform usual Doctrine DebugStack stopQuery() and trigger event for loggers
  * 
  * Event argument is array:
  *   - 'sql'         => string SQL statement
  *   - 'params'      => array of bound parameters
  *   - 'types'       => array of parameter types
  *   - 'executionMS' => float of execution time in microseconds
  * 
  * @return void
  */
 public function stopQuery()
 {
     parent::stopQuery();
     \Xoops::getInstance()->events()->triggerEvent('core.database.query.complete', $this->queries[$this->currentQuery]);
 }
 public function stopQuery()
 {
     parent::stopQuery();
     if ((bool) $this->config['log_executiontime']) {
         $this->log($this->queries[$this->currentQuery]['executionMS']);
     }
 }