You can try this:
$oldprefix = $CFG->prefix; $CFG->prefix = 'myprefix_'; $DB->something; $CFG->prefix = $oldprefix;
You should also place appropriate try/catch and ensure that no exception leaves your code. You must also guarantee that $CFG->prefix will be set to original state.
This is still extremely bad idea.