以前的Query可以理解为
- 文章article有一个字段叫channel
- Channel关联到了taxonomy
- 查询taxonomy中的checkout_status字段值为1
// 获取一个Entity类型的Storage
$node_storage = \Drupal::entityTypeManager()->getStorage('node');
// 获取Query
$query = $node_storage->getQuery();
$query->condition('type', 'article');
$query->condition('channel.entity:taxonomy_term.checkout_status', 1);
$ids = $query->execute();
dpm($ids);
再来看一个多层链接的
- 文章article中有一个字段叫channel
- channel关联了taxonomy
- channel中一个字段叫车辆类型:vehicle_type
- vehicle_type又关联了taxonomy
- vehicle_type的名字叫汽车运输的
$node_storage = \Drupal::entityTypeManager()->getStorage('node');
$query = $node_storage->getQuery();
$query->condition('type', 'article');
$query->condition('channel.entity:taxonomy_term.vehicle_type.entity:taxonomy_term.name', '汽车运输');
$ids = $query->execute();
dpm($ids);