error try to connect to an other db

<%- if @topic_view.topic.tags.present? %>
<%= t 'js.tagging.tags' %>: <%- @topic_view.topic.tags.each do |t| %> <%= t %> <%- end %>
<% end %>

Silverstripe Version: 4.1 (php7)

Question:
I need o connect my project to an external db to execute some query.
What is wrong?

Error: Call to a member function isQueryDLL() on null

Details of your query go here

use  SilverStripe\ORM\Connect\MySQLDatabase;

global $mydb;
$mydb=new MySQLDatabase(array(
"server"=>"10.0.0.1",
"username"=>"admin",
"password"=>"admin",
"database"=>"my_db",
"type"=>"mysql",
));

$h=$mydb->query($sql);
$row=$h->nextRecord();