The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/showthread.php 28 require_once





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Connecting Multiple Installations
#5
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
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();
  Reply


Messages In This Thread
Connecting Multiple Installations - by Brandin - 04-15-2017, 01:26 PM
Connecting Multiple Installations - by JUG - 04-16-2017, 03:50 AM
Connecting Multiple Installations - by Brandin - 04-16-2017, 09:42 AM
Connecting Multiple Installations - by Brandin - 04-28-2017, 09:42 PM
Connecting Multiple Installations - by mudmin - 04-29-2017, 01:11 AM
Connecting Multiple Installations - by Brandin - 04-29-2017, 11:00 AM
Connecting Multiple Installations - by mudmin - 04-29-2017, 11:12 AM
Connecting Multiple Installations - by Brandin - 04-29-2017, 11:14 AM
Connecting Multiple Installations - by Brandin - 05-12-2017, 11:10 AM
Connecting Multiple Installations - by mudmin - 05-14-2017, 11:44 AM

Forum Jump:


Users browsing this thread: 2 Guest(s)