protected function DrupalEntity6Migration::query in Drupal-to-Drupal data migration 7.2
Query for basic node fields from Drupal 6.
Return value
Overrides DrupalMigration::query
1 call to DrupalEntity6Migration::query()
File
- d6/
entity.inc, line 48 - Implementation of DrupalEntityMigration for Drupal 6 sources.
Class
- DrupalEntity6Migration
- Handling specific to a Drupal 6 node source for entities.
Code
protected function query() {
$query = Database::getConnection('default', $this->sourceConnection)
->select('node', 'n')
->fields('n', array(
'nid',
'vid',
'language',
'title',
'uid',
'status',
'created',
'changed',
'comment',
'promote',
'moderate',
'sticky',
'tnid',
'translate',
))
->condition('type', $this->sourceType)
->orderBy('changed');
$query
->innerJoin('node_revisions', 'nr', 'n.vid=nr.vid');
$query
->fields('nr', array(
'body',
'teaser',
'format',
));
// Pick up simple CCK fields
$cck_table = 'content_type_' . $this->sourceType;
if (Database::getConnection('default', $this->sourceConnection)
->schema()
->tableExists($cck_table)) {
$query
->leftJoin($cck_table, 'f', 'n.vid=f.vid');
// The main column for the field should be rendered with
// the field name, not the column name (e.g., field_foo rather
// than field_foo_value).
$field_info = $this->version
->getSourceFieldInfo();
foreach ($field_info as $field_name => $info) {
if (isset($info['columns']) && !$info['multiple'] && $info['db_storage']) {
$i = 0;
foreach ($info['columns'] as $display_name => $column_name) {
if ($i++ == 0) {
$query
->addField('f', $column_name, $field_name);
}
else {
// The database API won't allow colons in column aliases, so we
// will accept the default alias, and fix up the field names later.
// Remember how to translate the field names.
$clean_name = str_replace(':', '_', $display_name);
$this->fixFieldNames[$clean_name] = $display_name;
$query
->addField('f', $column_name);
}
}
}
}
}
return $query;
}