We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Best practice using second database within module in 3.2.1

How Do I?

adlix's avatar
adlix
7 posts
9 years ago
adlix's avatar adlix

Hi, I’m developing a new module M3, which has to access data from a second database. All my models depend on this database m3, which is already added to config.php. Is there a best practise to switch the database within the module , e.g. in mod.m3.php?

I added a service in addon.setup.php

'services' =>array( 
                'm3db' => function ($addon) {
                    return new Database('m3');
                }
            )

Is this a solution? But how do my models know where to be retrieved?

Thanks for help.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.