Welcome Guest, Not a member yet? Register   Sign In
dinamic database connect ?
#1

(This post was last modified: 08-09-2023, 06:24 AM by arslanturk.)

How do we connect to a different database with live values from database table without group?

Code:
$db_db =
                [
                    'DSN'      => '',
                    'hostname' => 'localhost',
                    'username' => 'root',
                    'password' => '1234',
                    'database' => 'test',
                    'DBDriver' => 'MySQLi',
                    'DBPrefix' => '',
                    'pConnect' => false,
                    'DBDebug'  => true,
                    'charset'  => 'utf8',
                    'DBCollat' => 'utf8_general_ci',
                    'swapPre'  => '',
                    'encrypt'  => false,
                    'compress' => false,
                    'strictOn' => false,
                    'failover' => [],
                    'port'     => 3306,
                ];

$db1 = db_connect($db_db); //192.168.1.11
$table1 = $db1->query("select * from table_name")->getResultObject();
$db1->close();

other :

Code:
$db_db =
                [
                    'DSN'      => '',
                    'hostname' => '147.145.251.123',
                    'username' => 'root',
                    'password' => '1234',
                    'database' => 'test',
                    'DBDriver' => 'MySQLi',
                    'DBPrefix' => '',
                    'pConnect' => false,
                    'DBDebug'  => true,
                    'charset'  => 'utf8',
                    'DBCollat' => 'utf8_general_ci',
                    'swapPre'  => '',
                    'encrypt'  => false,
                    'compress' => false,
                    'strictOn' => false,
                    'failover' => [],
                    'port'     => 3306,
                ];

$db2 = db_connect($db_db);//147.241.14.....
$table2 = $db2->query("select * from table_name")->getResultObject();
$db2->close();


should it be like this ?
Reply
Reply




Theme © iAndrew 2016 - Forum software by © MyBB