While looking at your code, the only thing I see wrong, is when you try to load the second database:
$DB2=$this->load->database($config);
When you want to retrieve the database object, you have to pass TRUE in the second argument.
From the Codeigniter User Guide:
By setting the second parameter to TRUE (boolean) the function will return the database object.
So, your code should instead be:
$DB2=$this->load->database($config, TRUE);
That will make it work.