Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This is a quick class that I made that should allow you to connect to 3 databases using adoDB:</p> <pre><code>class Data { private static $_dbOne = null; private static $_dbTwo = null; private static $_dbThree = null; protected function __construct() { } /** * This function returns the database connection object * @return Object Database Connection */ public static function dbOne() { include_once(LIBRARY_PATH.'adodb5/adodb.inc.php'); if (null === self::$_dbOne) { $_connOne = 'mysql://username:password@www.server.com/database'; self::$_dbOne = &amp;ADONewConnection($_connOne); if (self::$_dbOne==false) { die('Could not connect to the database.'); } } return self::$_dbOne; } /** * This function returns the database connection object * @return Object Database Connection */ public static function dbTwo() { include_once(LIBRARY_PATH.'adodb5/adodb.inc.php'); if (null === self::$_dbTwo) { $_connTwo = 'mysql://username:password@www.server.com/database'; self::$_dbTwo = &amp;ADONewConnection($_connTwo); if (self::$_dbTwo==false) { die('Could not connect to the database.'); } } return self::$_dbTwo; } } /** * This function returns the database connection object * @return Object Database Connection */ public static function dbThree() { include_once(LIBRARY_PATH.'adodb5/adodb.inc.php'); if (null === self::$_dbThree) { $_connThree = 'mysql://username:password@www.server.com/database'; self::$_dbThree = &amp;ADONewConnection($_connThree); if (self::$_dbThree==false) { die('Could not connect to the database.'); } } return self::$_dbThree; } } </code></pre> <p>Here is an example of how you would use this class:</p> <pre><code>$sql = "SELECT * FROM *"; $results1 = Data::dbOne()-&gt;Execute($sql); $results2 = Data::dbTwo()-&gt;Execute($sql); $results3 = Data::dbThree()-&gt;Execute($sql); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload