You are here

public function MigrateSQLMap::getQualifiedMapTable in Migrate 7.2

Same name and namespace in other branches
  1. 6.2 plugins/sources/sqlmap.inc \MigrateSQLMap::getQualifiedMapTable()

Qualifying the map table name with the database name makes cross-db joins possible. Note that, because prefixes are applied after we do this (i.e., it will prefix the string we return), we do not qualify the table if it has a prefix. This will work fine when the source data is in the default (prefixed) database (in particular, for simpletest), but not if the primary query is in an external database.

Return value

string

File

plugins/sources/sqlmap.inc, line 35
Defines a Drupal db-based implementation of MigrateMap.

Class

MigrateSQLMap
@file Defines a Drupal db-based implementation of MigrateMap.

Code

public function getQualifiedMapTable() {
  $options = $this->connection
    ->getConnectionOptions();
  $prefix = $this->connection
    ->tablePrefix($this->mapTable);
  if ($prefix) {
    return $this->mapTable;
  }
  else {
    $dbname = $options['database'];
    if (!empty($options['driver']) && $options['driver'] == 'mysql') {

      // Backtick the db name on mysql to ensure dbs with hyphens work.
      $dbname = "`{$dbname}`";
    }
    return $dbname . '.' . $this->mapTable;
  }
}