Jump to content

Plugin for external database


CodePixel

Recommended Posts

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! 🙂

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...