You are here

function joomla_database_init in Joomla to Drupal 6

Same name and namespace in other branches
  1. 7.2 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().

4 calls to joomla_database_init()
joomla_import_categories in ./joomla.module
joomla_import_content in ./joomla.module
joomla_import_users in ./joomla.module
joomla_myblog_map_form in ./joomla_myblog.module

File

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

Code

function joomla_database_init() {
  global $db_url;

  // $db_url must be in the array format
  if (!is_array($db_url)) {
    $db_url = array(
      'default' => $db_url,
    );
  }
  if (empty($db_url['joomla'])) {

    /**
     * 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
     */
    $engine = substr($db_url['default'], 0, strpos($db_url['default'], ':'));

    // same engine for two db: Drupal's limit
    $joomla_url = sprintf('%s://%s:%s@%s:%d/%s', $engine, variable_get('joomla_database_user', JOOMLA_DATABASE_USER), variable_get('joomla_database_pass', JOOMLA_DATABASE_PASS), variable_get('joomla_database_host', JOOMLA_DATABASE_HOST), variable_get('joomla_database_port', JOOMLA_DATABASE_PORT), variable_get('joomla_database_name', JOOMLA_DATABASE_NAME));
    $db_url['joomla'] = $joomla_url;
  }
}