EntityFieldQuery join
<?php
join entities
$query->entityCondition('entity_type', array('profile2','user'))
->entityCondition('bundle', array('user_profile','property'), 'IN');
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node')
->entityCondition('bundle', 'product')
->range(0,500);
$results = $query->execute();
foreach ($results['node'] as $record) {
$id = $record->nid;
entity_delete('node', $id);
}
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node')
->entityCondition('bundle', 'programs');
$results = $query->execute();
foreach ($results['node'] as $record) {
$id = $record->nid;
$entity = entity_load_single('node', $id);
entity_save('node', $entity);
}
// Execute EntityFieldQuery as account
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node')
->entityCondition('bundle', 'article')
->propertyCondition('status', NODE_PUBLISHED)
->fieldCondition('field_news_types', 'value', 'spotlight', '=')
->fieldCondition('field_photo', 'fid', 'NULL', '!=')
->fieldCondition('field_faculty_tag', 'tid', $value)
->fieldCondition('field_news_publishdate', 'value', $year . '%', 'like')
->fieldOrderBy('field_photo', 'fid', 'DESC')
->range(0, 10)
->addMetaData('account', user_load(1)); // Run the query as user 1.
$result = $query->execute();
if (isset($result['node'])) {
$news_items_nids = array_keys($result['node']);
$news_items = entity_load('node', $news_items_nids);
}
// ---------------------------------------------
$query = new EntityFieldQuery;
$results = $query
->entityCondition('entity_type', 'node')
->propertyCondition('type', 'asset')
->fieldCondition('field_assetcategory', 'target_id' ,'273722')
->execute();
dpm( $results);
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'entity_test');
$query->entityCondition('langcode', $default_langcode);
$query->propertyCondition('user_id', $properties[$default_langcode]['user_id'], NULL, 'original');
$query->propertyCondition('name', $properties[$default_langcode]['name'], NULL, 'original');
$query->propertyLanguageCondition($default_langcode, NULL, 'original');
$query->propertyCondition('name', $properties[$langcode]['name'], NULL, 'translation');
$query->propertyLanguageCondition($langcode, NULL, 'translation');
$query->fieldCondition($this->field_name, 'value', $field_value, NULL, NULL, 'translation');
$query->fieldLanguageCondition($this->field_name, $langcode, NULL, NULL, 'translation');
$query->propertyOrderBy('name', 'ASC', 'original');
$result = $query->execute();
$query = new EntityFieldQuery;
$results = $query
->entityCondition('entity_type', 'node')
->propertyCondition('type', 'asset')
->execute();
foreach ($results['node'] as $record) {
$id[] = $record->nid;
}
$entities = entity_load('node', $id);
foreach ($entities as $entity) {
$entity->field_filename['und'][0]['value'] = $entity->field_assetimage['und'][0]['filename'];
entity_save('node', $entity);
}
$query = new EntityFieldQuery;
$results = $query
->entityCondition('entity_type', 'node')
->propertyCondition('type', 'variant')
->propertyCondition('nid', array(541000, 541500), 'between')
->range(0, 50)
->execute();
foreach ($results['node'] as $record) {
$id = $record->nid;
entity_delete('node', $id);
}
$query = new EntityFieldQuery;
$results = $query
->entityCondition('entity_type', 'node')
->propertyCondition('type', 'nodefile')
->propertyCondition('status', '1')
->propertyCondition('nid', array(500, 600), 'between')
->range(0,100)
->execute();
foreach ($results['node'] as $record) {
$id = $record->nid;
//dpm( $id );
$entity = entity_load_single('node', $id);
$entity->status = 0;
entity_save('node', $entity);
//break;
}
offline
$query = new EntityFieldQuery;
$results = $query
->entityCondition('entity_type', 'node')
->propertyCondition('type', 'nodefile')
->range(0,100)
->execute();
foreach ($results['node'] as $record) {
$id = $record->nid;
$entity = entity_load_single('node', $id);
$entity ->field_offline['und'][0]['value']= 0;
entity_save('node', $entity);
}
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'user')
->fieldCondition('field_user_payroll', 'value', $payroll, '=');
$results = $query->execute();
$users = user_load_multiple(array_keys($results['user']));
foreach($users as $user) {
$wrapper = entity_metadata_wrapper('user', $account);
$mimemail = $wrapper->mimemail->raw();
watchdog('Photo Import', "Mimemail: %mimemail", array('%mimemail' => $mimemail), WATCHDOG_INFO);
}
// taxonomy
$query = new EntityFieldQuery();
$query
->entityCondition('entity_type', 'taxonomy_term')
->entityCondition('bundle', 'fund_code')
->propertyCondition('name', $fund_code)
$results = $query->execute();
foreach($results['taxonomy_term'] as $tid) {
$term = taxonomy_term_load($tid);
dpm($term);
$items = field_get_items('taxonomy_term', $term, 'code_description');
dpm($items);
}
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node')
->entityCondition('bundle', 'article')
->propertyCondition('status', NODE_PUBLISHED)
->fieldCondition('field_news_types', 'value', 'spotlight', '=')
// See the comment about != NULL above.
->fieldCondition('field_photo', 'fid', 'NULL', '!=')
->fieldCondition('field_faculty_tag', 'tid', $value)
->fieldCondition('field_news_publishdate', 'value', $year . '%', 'like')
->fieldOrderBy('field_photo', 'fid', 'DESC')
->range(0, 10)
// Run the query as user 1.
->addMetaData('account', user_load(1));
$result = $query->execute();
if (isset($result['node'])) {
$news_items_nids = array_keys($result['node']);
$news_items = entity_load('node', $news_items_nids);
}
NODE_PUBLISHED
?>