Comments (2)
You could do so by essentially copying the config for Zend\Db\Adapter\Adapter
and renaming the array keys to something descriptive for your database.
For example:
return array(
'service_manager' => array(
'factories' => array(
'db-master' => function ($sm) use ($dbParams) {
//setup
},
'db-slave' => function ($sm) use ($dbParams) {
//setup
}
)
)
);
from bjyprofiler.
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.
from bjyprofiler.
Related Issues (20)
- feature for abstract factories HOT 1
- UTF8 encoding using PDO HOT 1
- Cannot create a custom adapter into Module.php
- Logging profiler does not print QUERY_MODE_EXECUTE queries
- Multiple Db configuration HOT 1
- Incompatible with ZF 2.3 HOT 7
- Module (bjyoungblood/bjy-profiler) could not be initialized HOT 2
- Add driver_options to the default config autoload
- doctrine support HOT 1
- HTML in config smashes the Toolbar HOT 1
- [ZF2] MasterSlaveFeature (TableGateway) breaks the db-profiler
- ZF2 + Doctrine 2 + BjyProfiler + SQLite3
- Profiler::profilerStart() fails when given string parameter
- New release
- Installation with new ZendSkeletonApplication installs all components HOT 2
- ZF3, ProfilingAdapterFactory does not implement __invoke HOT 3
- How to configure profiler with zend-db Pdo_Pgsql driver? HOT 4
- Issue with zend framework 3 HOT 5
- ZF3 - The supplied or instantiated driver object does not implement Zend\Db\Adapter\Driver\DriverInterface
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bjyprofiler.