You are here

protected function DrupalTerm5Migration::query in Drupal-to-Drupal data migration 7.2

Implementation of DrupalTermMigration::query().

Return value

SelectQueryInterface

Overrides DrupalMigration::query

File

d5/taxonomy.inc, line 24
Implementation of DrupalTermMigration for Drupal 5 sources.

Class

DrupalTerm5Migration
Handling specific to a Drupal 5 source for taxonomy terms.

Code

protected function query() {

  // Note the explode - this supports the (admittedly unusual) case of
  // consolidating multiple vocabularies into one.
  $query = Database::getConnection('default', $this->sourceConnection)
    ->select('term_data', 'td')
    ->fields('td', array(
    'tid',
    'name',
    'description',
    'weight',
  ))
    ->condition('vid', explode(',', $this->sourceVocabulary), 'IN')
    ->orderBy('th.parent')
    ->distinct();

  // Join to the hierarchy so we can sort on parent, but we'll pull the
  // actual parent values in separately in case there are multiples.
  $query
    ->leftJoin('term_hierarchy', 'th', 'td.tid=th.tid');
  return $query;
}