实体字段查询中的多个实体类型
如何在EntityFieldQuery
中添加多个entity_type和绑定?实体字段查询中的多个实体类型
$query->entityCondition('entity_type', 'profile2')
->entityCondition('bundle', 'user_profile');
有没有什么办法可以做到这一点?
$query->entityCondition('entity_type', array('profile2','user'))
->entityCondition('bundle', array('user_profile','property'));
在官方doc:
public EntityFieldQuery::entityCondition($name, $value, $operator = NULL)
其中:
$命名: 'ENTITY_TYPE', '束', 'REVISION_ID' 或 'ENTITY_ID'。
$ value:$ name的值。在大多数情况下,这是一个标量。对于更复杂的选项,它是阵列。 中每个元素的含义取决于$ 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.
我想你忘记了运营商!
感谢您的参考。 – 2014-09-06 06:26:06
它解决了你的问题吗?如果是的话,不要忘记将这个答案标记为关闭该主题的良好答案。 – Djouuuuh 2014-09-06 10:41:18
这是不可能的:https://api.drupal.org/api/drupal/includes%21entity.inc/class/EntityFieldQuery/7
该类允许求解基于实体属性的实体(例如,节点 - >改变),字段值,和通用实体元数据(束,实体类型,实体ID和修订ID)。 不可能跨多种实体类型进行查询。例如,没有工具可以查找过去一小时内创建的用户编写的发布节点,因为这需要查询node-> status和user-> created。
你甚至尝试过吗?根据文件,它应该像这样工作。 – 2014-09-05 15:21:35
它适用于单一实体类型。 – 2014-09-06 06:25:18