
<?php
$db = JFactory::getDbo();
?>

<?php
$option = array(); //prevent problems
$option['driver'] = 'mysql'; // Database driver name
$option['host'] = 'localhost'; // Database host name
$option['user'] = 'root'; // User for database authentication
$option['password'] = ''; // Password for database authentication
$option['database'] = 'another_db'; // Database name
$option['prefix'] = 'pre_'; // Database prefix (may be empty)
$db = JDatabase::getInstance( $option );
?>
$db is now an object of type JDatabase and you can perform database operations on it using the usual methods.