04-29-2017, 01:11 AM
I just wrote you something to connect to two databases without editing any core files.
***Step 1***
Save this file as DB2.php and put it in users/classes
https://pastebin.com/8r1qSzZ1
***Step 2***
Then, backup your existing init.php file and edit it....Take the section around line 25 and change it from...
(obviously using your own db credentials for the first and second db)
$GLOBALS['config'] = array(
'mysql' => array('host'=> 'localhost',
'username' => 'root',
'password' => '',
'db' => '422',
),
'remember' => array(
TO
$GLOBALS['config'] = array(
'mysql' => array('host'=> 'localhost',
'username' => 'root',
'password' => '',
'db' => '422',
),
'mysql2' => array('host2'=> 'localhost',
'username2' => 'root',
'password2' => '',
'db2' => '423',
),
'remember' => array(
***Step 3***
Later in init.php, right after the include of DB.php add
require_once $abs_us_root.$us_url_root.'users/classes/DB2.php';
***Step 4***
In usersc/includes/navigation.php change lines 1 and 2 from
to
Then you just make your queries like this...
***Step 1***
Save this file as DB2.php and put it in users/classes
https://pastebin.com/8r1qSzZ1
***Step 2***
Then, backup your existing init.php file and edit it....Take the section around line 25 and change it from...
(obviously using your own db credentials for the first and second db)
$GLOBALS['config'] = array(
'mysql' => array('host'=> 'localhost',
'username' => 'root',
'password' => '',
'db' => '422',
),
'remember' => array(
TO
$GLOBALS['config'] = array(
'mysql' => array('host'=> 'localhost',
'username' => 'root',
'password' => '',
'db' => '422',
),
'mysql2' => array('host2'=> 'localhost',
'username2' => 'root',
'password2' => '',
'db2' => '423',
),
'remember' => array(
***Step 3***
Later in init.php, right after the include of DB.php add
require_once $abs_us_root.$us_url_root.'users/classes/DB2.php';
***Step 4***
In usersc/includes/navigation.php change lines 1 and 2 from
Code:
<?php
Code:
?>
to
Code:
<?php $db2 = DB2::getInstance(); ?>
Then you just make your queries like this...
Code:
$query = $db2->query("SELECT * FROM users");
Code:
$count = $query->count();