You are here

function joomla_database_init in Joomla to Drupal 7.2

Same name and namespace in other branches
  1. 6 joomla.module \joomla_database_init()
  2. 7 joomla.module \joomla_database_init()

Initialise settings for communicating with the Joomla database. This makes it possible to switch between the Drupal and Joomla databases with db_set_active().

2 calls to joomla_database_init()
joomla_batch_save in ./joomla.batch.inc
joomla_myblog_map_form in ./joomla_myblog.module

File

./joomla.module, line 455
The joomla module used for migrate Joomla to Drupal.

Code

function joomla_database_init() {
  $joomla_db = Database::getConnectionInfo('joomla');
  if (empty($joomla_db)) {

    /**
     * It's not possible to use a combination of database engines, e.g.
     * mysql and mysqli, at the same time.  So, determine which one is
     * in use on the Drupal site and use it for the Joomla connection
     */
    $dbs = Database::getConnectionInfo('default');

    // same engine for two db: Drupal's limit
    $engine = $dbs['default']['driver'];
    $joomla_url = array(
      'database' => variable_get('joomla_database_name', JOOMLA_DATABASE_NAME),
      'username' => variable_get('joomla_database_user', JOOMLA_DATABASE_USER),
      'password' => variable_get('joomla_database_pass', JOOMLA_DATABASE_PASS),
      'host' => variable_get('joomla_database_host', JOOMLA_DATABASE_HOST),
      'port' => variable_get('joomla_database_port', JOOMLA_DATABASE_PORT),
      'prefix' => variable_get('joomla_prefix', JOOMLA_PREFIX),
      'driver' => $engine,
    );
    Database::addConnectionInfo('joomla', 'default', $joomla_url);
  }
}