On my D7 site, when a user creates an account, a single node of a particular type (TYPE A PROFILE) is created for them, and they then edit it and complete a 'Minimum acceptable value' field. There are also TYPE B PROFILE nodes, which have a 'Value' field.

I've created a view of all the TYPE B PROFILE nodes, and need to display only the nodes where the 'Value' is greater than or equal to the 'Minimum acceptable value' of the TYPE A PROFILE node authored by the currently logged in user (that's a mouthful!). I'm trying to accomplish this with a Views PHP filter with the following code, and would really appreciate some guidance!

FILTER CODE:

    global $user;
    $uid = user_load($user->uid);
    // Get all nodes from user that are of type_a_profile and are published
    $query = new EntityFieldQuery();
    $query
      ->entityCondition('entity_type', 'node')
      ->entityCondition('bundle', 'type_a_profile')
      ->propertyCondition('status', 1)
      ->propertyCondition('uid', $uid)
      ->fieldCondition('field_min_value', 'value', 'NULL', '!='); //'Minimum acceptable value' is not null

    $result = $query->execute();
    $nids = array_keys($result['node']);

    $nodes = node_load_multiple($nids);
    foreach ($nodes as $node) {
      $nid = $node->nid;
      $min_value = $node->field_min_value;
    }
    if ($min_value >= $data->field_value) {
      return true;
    }

* I'm not actually using the php delimiters in the Filter Code.

Couple questions: 1) How can I load just one node (as there will only be one). 2) Am I calling the field properly ($min_value = $node->field_min_value;).

Finally, the main question, should this work? Or is there a better way to do this? With this code as is, I'm getting the following error - Recoverable fatal error: Object of class stdClass could not be converted to string in DatabaseStatementBase->execute() (line 2168 of /xxxx/xxxx/public_html/includes/database/database.inc).

Thanks in advance for any help!