简体   繁体   English

实体字段查询中的多个实体类型

[英]multiple entity type in entity field query

How to add multiple entity_type and bundles in EntityFieldQuery ? 如何在EntityFieldQuery添加多个entity_type和bundle?

$query->entityCondition('entity_type', 'profile2')
       ->entityCondition('bundle', 'user_profile');

Is there any way to do like this? 有什么办法可以这样吗?

$query->entityCondition('entity_type', array('profile2','user'))
       ->entityCondition('bundle', array('user_profile','property'));

This isn't possible: https://api.drupal.org/api/drupal/includes%21entity.inc/class/EntityFieldQuery/7 这是不可能的: https : //api.drupal.org/api/drupal/includes%21entity.inc/class/EntityFieldQuery/7

This class allows finding entities based on entity properties (for example, node->changed), field values, and generic entity meta data (bundle, entity type, entity id, and revision ID). 此类允许根据实体属性(例如,node-> changed),字段值和通用实体元数据(捆绑,实体类型,实体ID和修订ID)查找实体。 It is not possible to query across multiple entity types. 无法跨多种实体类型进行查询。 For example, there is no facility to find published nodes written by users created in the last hour, as this would require querying both node->status and user->created. 例如,无法查找上一小时创建的用户编写的已发布节点,因为这将需要同时查询node-> status和user-> created。

In the official doc : 在官方文档中

public EntityFieldQuery::entityCondition($name, $value, $operator = NULL)

where: 哪里:

$name : 'entity_type', ' bundle ', 'revision_id' or 'entity_id'. $ name :“ entity_type”,“ bundle ”,“ revision_id”或“ entity_id”。

$value : The value for $name. $ value :$ name的值。 In most cases, this is a scalar. 在大多数情况下,这是一个标量。 For more complex options, it is an array . 对于更复杂的选项,它是一个array The meaning of each element in the array is dependent on $operator . 数组中每个元素的含义取决于$ operator

$operator : Possible values: $ operator :可能的值:

'=', '<>', '>', '>=', '<', '<=', 'STARTS_WITH', 'CONTAINS': These operators expect $value to be a literal of the same type as the column.
'IN', 'NOT IN': These operators expect $value to be an array of literals of the same type as the column.
'BETWEEN': This operator expects $value to be an array of two literals of the same type as the column.

I guess you forgot the operator! 我猜你忘了操作员!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM