Good morning,
I am wondering if it would be possible to use $DB to query a database outside of the Moodle one but on the same server? The only thing that would change in regards to the connection information would be the database name. So instead of moodle.mdl_users it would be neighbor.table.
I know I can create a script on the server with the connection information and use a mysqli_connection to create a new connection but I would prefer to use the Moodle database query system if possible.