How to select nodes of a certain type, created by a certain user and which have reference field to a node equal a certain nid? function mymodule_get_nodes_by_user_referencing_nid($type, $userid, $referncenid) {
    return node_load_multiple(array(), array('type' =&gt; $type, 'uid' =&gt; $userid, ??? =&gt; ???));
}


I need a function that lists nodes by following this logic: give me all nodes of a given type which are created by a given user and which have a node reference field referencing a given node id.

Any ideas about such function (in PHP, not in Views)
)?
This code assumes you're using the entityreference module using field name "field_reference":

$query = new EntityFieldQuery();
$query-&gt;entityCondition('entity_type', 'node');
$query-&gt;propertyCondition('type', $type);
$query-&gt;propertyCondition('uid', $userid);
$query-&gt;fieldCondition('field_reference', 'target_id', $referenceid);
$result = $query-&gt;execute();

$nodes = array();
if (!empty($result['node'])) {
  $nodes = node_load_multiple(array_keys($result['node']));
}