Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
szalik.dev Posted September 22, 2018 Posted September 22, 2018 Hi, I've created plugin, which should ONLY connect to external database (i've accomplished that) and now i want to use this connection in second plugin. I'm using this plugin as "core" and some kind of protection (when somehow anyone gets my plugins, they can't use it without it) I will be gratefull for any answers! 🙂
bfarber Posted September 24, 2018 Posted September 24, 2018 When you create the connection you can specify an identifier. Your other plugins can just look for/use that identifier. $db = \IPS\Db::i( 'myconnection', array( ... details ) ); Do this early in code execution, and then in your other plugins you can just use \IPS\Db::i( 'myconnection' )->select( ... ); After the connection is established, it is available and cached and referenced by the identifier. When no identifier is passed, it just defaults to "__MAIN" which represents the connection based on the settings in conf_global.php.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.