Multiple database connection, last connection is overwriting
`<?php class Database extends Base{
//defautl array of database settings(this will be configured differently later on);
public static $DbSettings = array(
'api' => array(
'driver' => 'mysql',
'host' => DB_HOST,
'database' => 'api',
'username' => 'root',
'password' => 'usbw',
'charset' => 'utf8'
),
'test_1' => array(
'driver' => 'mysql',
'host' => DB_HOST,
'database' => 'test_1',
'username' => 'root',
'password' => 'usbw',
'charset' => 'utf8'
),
'test_2' => array(
'driver' => 'mysql',
'host' => DB_HOST,
'database' => 'test_2',
'username' => DB_USER,
'password' => DB_PASS,
'charset' => 'utf8'
)
);
//initialize database
static function Init($data = null) {
//default config
//check whom the concerned environment is, if it specified it is the specified environment otherwise its the default environment
if(isset(self::$Data['URL']['Environment'])){
$environment_config = self::$DbSettings[strtolower(self::$Data['URL']['Environment'])];
$connection_environment = new \Pixie\Connection('mysql',$environment_config, 'Environment_DB');
}
$api_config = self::$DbSettings['api'];
$connection_api = new \Pixie\Connection('mysql', $api_config, 'API_DB');
$c3_config = self::$DbSettings['test_2'];
$connection_c3 = new \Pixie\Connection('mysql', $c3_config, 'C3_DB');
}
static function Connect(){
}
} `
When I'm executing the above code when I call API_DB::Table() etc. in a controller. It says cant find the table: "Given_table" in test_2_db If i Swap $api config, $connection_api and $c3_config, $connection_c3 around it works.
But then if i call for example: C3_DB::Table() balbablabla it says: Cant fint the table "Given_table" in API_DB.
So the last databse connection is always the one used what am i doing wrong
https://github.com/usmanhalalit/pixie/pull/154/commits/a8891fef63ac02e10da15a44a27daaefe5aa311c I made a fix for it. It should work.
@luccas641 can you get around the eval() I really want to merge this.