/**
  * @param ServiceLocatorInterface $serviceLocator
  * @return mixed
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $config = $serviceLocator->get('Configuration');
     $dbParams = $config['db'];
     $adapter = new ProfilingAdapter($dbParams);
     $adapter->setProfiler(new Profiler());
     if (isset($dbParams['options']) && is_array($dbParams['options'])) {
         $options = $dbParams['options'];
     } else {
         $options = array();
     }
     $adapter->injectProfilingStatementPrototype($options);
     return $adapter;
 }
Esempio n. 2
0
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $adapter = new \BjyProfiler\Db\Adapter\ProfilingAdapter(array('driver' => 'pdo', 'dsn' => 'mysql:dbname=radius;host=127.0.0.1', 'database' => 'radius', 'username' => 'root', 'password' => '1234', 'hostname' => '127.0.0.1'));
     if (php_sapi_name() == 'cli') {
         $logger = new Zend\Log\Logger();
         // write queries profiling info to stdout in CLI mode
         $writer = new Zend\Log\Writer\Stream('php://output');
         $logger->addWriter($writer, Zend\Log\Logger::DEBUG);
         $adapter->setProfiler(new \BjyProfiler\Db\Profiler\LoggingProfiler($logger));
     } else {
         $adapter->setProfiler(new \BjyProfiler\Db\Profiler\Profiler());
     }
     if (isset($dbParams['options']) && is_array($dbParams['options'])) {
         $options = $dbParams['options'];
     } else {
         $options = array();
     }
     $adapter->injectProfilingStatementPrototype($options);
     return $adapter;
 }