Reputation: 31610
I want to make sure this works the way I think it does.
I have setup DB info inside of myapp/config/autoload/global.php like this:
return array(
'db' => array(
'driver' => 'Pdo',
'dsn' => 'mysql:dbname=zf2tutorial;host=localhost',
'driver_options' => array(
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\''
),
),
...
Now I'm messing around with a new module and would like to configure that specific module with a different db. If I add a 'db' config array to NewModule/config/module.config.php will it overwrite the global config? I'm not sure if the application wide global.php file is the same as a module specific config file or if it has a special specification- like accepting a db configuration while module specific config files do not.
edit: Well I tried this and it appears the db entry I added in module.config is being completely ignored. How can I override the db config per module? It would be very convenient for testing purposes.
Upvotes: 0
Views: 488
Reputation: 33148
If I add a 'db' config array to NewModule/config/module.config.php will it overwrite the global config?
Yes. All configs are merged together in to one monster array.
ZF support multiple adapters, you'll just have to refer to them by name in code so it knows which one you want. See this blog post for details on how to set it up: http://samsonasik.wordpress.com/2013/07/27/zend-framework-2-multiple-named-db-adapter-instances-using-adapters-subkey/
Upvotes: 2