使用实体字段查询搜索多个字段的最佳方法?

What's the best way to use Entity Field Query to search multiple fields? I have a content type called "Projects" that has custom fields for "Project Manager" and "Developer, which are references to users, and I am trying to display a list of projects a given user is associated with on each user's profile.

This is what I have so far:

<?php
  // Print all projects associated with this user
  $profile = user_load(arg(1));
  // Check database for reference to this user in pm field
  $query = new EntityFieldQuery();
  $result = $query->entityCondition('entity_type', 'node')
          ->entityCondition('bundle', 'project')
          ->propertyCondition('status', 1)
          ->fieldCondition('<insert multiple fields here..?>', 'target_id', $profile->uid, '=')
          ->execute();


  if (!empty($result['node'])) {
    $nids = array_keys($result['node']);
    $nodes = node_load_multiple(array_keys($result['node']));
    echo "<b>User's projects:<br></b>";
  }
  // display projects
  foreach ($nodes as &$node) {
    $targetPath = "content/";
    $targetPath .= str_replace(' ', '-', $node->title);
    $targetPath = 'http://'.$_SERVER['HTTP_HOST'].base_path().drupal_get_path_alias($targetPath, $path_language = '');
    echo "<a href='$targetPath'>$node->title</a><br>";
  }

?>

It seems that you need to load users based on [field_1] OR [field_2] values.

<?php
    // Print all projects associated with this user
    $profile = user_load(arg(1));
    // Check database for reference to this user in pm field
    $query = new EntityFieldQuery();
    $result_1 = $query->entityCondition('entity_type', 'node')
        ->entityCondition('bundle', 'project')
        ->propertyCondition('status', 1)
        ->fieldCondition('field_1', 'target_id', $profile->uid, '=')
        ->execute();

    $query = new EntityFieldQuery();
    $result_2 = $query->entityCondition('entity_type', 'node')
        ->entityCondition('bundle', 'project')
        ->propertyCondition('status', 1)
        ->fieldCondition('field_2', 'target_id', $profile->uid, '=')
        ->execute();

    $results = array();

    // 1st Set
    if (!empty($result_1['node'])) {
        $results = array_keys($result_1['node']);
    }
    // 2nd Set
    if (!empty($result_2['node'])) {
        $results += array_keys($result_2['node']);
    }

    if (count($results)) {
            $nodes = node_load_multiple($results);
            echo "<b>User's projects:<br></b>";

            // display projects
            foreach ($nodes as &$node) {
                $targetPath = "content/";
                $targetPath .= str_replace(' ', '-', $node->title);
                $targetPath = 'http://'.$_SERVER['HTTP_HOST'].base_path().drupal_get_path_alias($targetPath, $path_language = '');
                echo "<a href='$targetPath'>$node->title</a><br>";
            }
    }
?>

Also, please remember to use Drupal 7 functions like l() & t().

Instead of:

echo "<a href='$targetPath'>$node->title</a><br>";

Write:

echo l($node->title, $targetPath)."<br>";

You will be surprised. :)

Docs:

https://api.drupal.org/api/drupal/includes%21common.inc/function/l/7 https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/t/7