コード例 #1
0
 /**
  * {@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) . ')');
     }
 }
コード例 #2
0
ファイル: DbalLogger.php プロジェクト: netixpro/symfony
 /**
  * {@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)) . ')');
     }
 }
コード例 #3
0
 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);
 }
コード例 #4
0
 /**
  * {@inheritdoc}
  */
 public function startQuery($sql, array $params = null, array $types = null)
 {
     if ($this->enabled) {
         $e = new \Exception();
         $this->callstack = $e->getTraceAsString();
     }
     if (null !== $this->stopwatch) {
         $this->stopwatch->start('doctrine');
     }
     parent::startQuery($sql, $params, $types);
 }
コード例 #5
0
 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());
 }
コード例 #6
0
ファイル: DbalLogger.php プロジェクト: ygeneration666/ec
 /**
  * {@inheritdoc}
  */
 public function startQuery($sql, array $params = null, array $types = null)
 {
     parent::startQuery($sql, $params, $types);
     if (null !== $this->stopwatch) {
         $this->stopwatch->start('doctrine', 'doctrine');
     }
     if (is_array($params)) {
         $params = $this->fixParams($params);
     }
     if (null !== $this->logger) {
         $this->log($sql, null === $params ? array() : $params);
     }
 }
コード例 #7
0
 /**
  * @param string $sql
  * @param array $params
  * @param array $types
  */
 public function startQuery($sql, array $params = null, array $types = null)
 {
     $assembled = $sql;
     if (!empty($params)) {
         foreach ($params as $key => $param) {
             $type = $this->mapType($types, $key, $param);
             if (null === $type) {
                 $this->log('Param could not be prepared: key: "' . $key . '", value "' . var_export($param, true) . '"!');
                 $assembled = join('?', explode('?', $assembled, 2));
             } else {
                 $value = $type->convertToDatabaseValue($param, $this->getDatabasePlatform());
                 $assembled = join($this->prepareValue($type, $value), explode('?', $assembled, 2));
             }
         }
     }
     $this->log($assembled);
     parent::startQuery($sql, $params, $types);
 }