I need to add sql logging to work in native WebProfileBundle. When I do one default connection in application config, I see the sql queries in my log. But my application uses many connections to many db servers, so I can't add all the possible connections to config file.
I create runtime connections, i.e.:
$config = array(
        'user' => 'user1',
        'password' => 'pass1',
        'driver' => 'pdo_mysql',
        'port' => 3306,
);
$conn = DriverManager::getConnection($config);
then I think, should be command something like this
$conn->getConfiguration()->getSQLLogger($someLoggerObject);
I've tried to solve t开发者_JAVA技巧his problem with DependencyInjection, took DoctrineBundle as example. But have no luck.
Any help with live code or link to proper documentation would be great
I have this in my conf:
$config = new Configuration;
/** configuration stuff */
$config->setSQLLogger(MyLogger::getInstance());
$connectionOptions = array(
            'driver' => 'pdo_mysql',
            'user' => DB_USER,
            'password' => DB_PASS,
            'host' => DB_HOST,
            'dbname' => DB_NAME,
            'charset' => 'utf8',
            'driverOptions' => array(
                    'charset' => 'utf8'
            )
    );
$em = EntityManager::create($connectionOptions, $config);
I use Zend + Doctrine2 and that is in my bootstrap, my logger is a singleton (thats why getInstance). I've never user DriverManager, but i hope this helps.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论