我需要查询一个drupal 站点。最初我只需要计算内容类型的节点数:
$query = "SELECT COUNT(*) amount FROM {node} n WHERE n.type ='A'";
$result = db_query($query)->fetch();
return $result->amount;
现在我需要它,但仅适用于 field_b 等于“X”的节点。我怎样才能做到这一点?
I tried EntityFieldQuery without sucess:
$query = new EntityFieldQuery;
$query->entityCondition('entity_type', 'node')
->entityCondition('bundle', 'A')
->fieldCondition('field_b', 'value', 'X');
$results = $query->execute();
return $results->amount;
有什么帮助吗?