This repository has been archived by the owner on Jan 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 55
Multiple Database Configuration #47
Comments
You could do so by essentially copying the config for For example:
|
Hello, @bjyoungblood . My configuration files are as follows: // config/autoload/global.php
<?php return array(
'db' => array(
'driver' => 'Pdo',
'dsn' => 'mysql:dbname=spinfo_blog;host=localhost',
'username' => 'root',
'password' => '123456',
//other adapters...
'adapters' => array(
'user-db-driver' => array(
'driver' => 'Pdo',
'dsn' => 'mysql:dbname=spinfo_users;host=localhost',
'username' => 'root',
'password' => '123456',
),
'image-db-driver' => array(
'driver' => 'Pdo',
'dsn' => 'mysql:dbname=spinfo_images;host=localhost',
'username' => 'root',
'password' => '123456',
)
)
),
'service_manager' => array(
'factories' => array(
'Zend\Db\Adapter\Adapter' => 'Zend\Db\Adapter\AdapterServiceFactory',
),
// to allow other adapters based on the adapters config.
'abstract_factories' => array(
'Zend\Db\Adapter\AdapterAbstractServiceFactory'
)
)
); And <?php
//config/autoload/bjyprofiler.local.php
$prepareAdapter = function($dbParams) {
$adapter = new BjyProfiler\Db\Adapter\ProfilingAdapter($dbParams);
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;
};
return array(
'service_manager' => array(
'factories' => array(
'db' => function (\Zend\ServiceManager\ServiceManager $sm) use ($prepareAdapter) {
$config = $sm->get('Config');
$dbParams = $config['db'];
return $prepareAdapter($dbParams);
},
'user-db-driver' => function (\Zend\ServiceManager\ServiceManager $sm) use ($prepareAdapter) {
$config = $sm->get('Config');
$dbParams = $config['db']['adapters']['user-db-driver'];
return $prepareAdapter($dbParams);
},
'image-db-driver' => function (\Zend\ServiceManager\ServiceManager $sm) use ($prepareAdapter) {
$config = $sm->get('Config');
$dbParams = $config['db']['adapters']['image-db-driver'];
return $prepareAdapter($dbParams);
}
),
),
); But it shows, "You have to install or enable @bjyoungblood's Zend\Db Profiler to use this feature." like . Please help me use this nice module. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hi!
Is it possible to configure multiple databases for databases profiling?
If not possible for now, then it might be a good feature to develop.
Thank you!
The text was updated successfully, but these errors were encountered: