EntityFieldQuery in rules - no result I try to set a new variable in rules. I try to get nid of a node selected by efq like this: 

&lt;?php
$termid = $node-&gt;field_terms['und'][0]['tid'];
$query = new EntityFieldQuery();
$query-&gt;entityCondition('entity_type', 'node')
-&gt;entityCondition('bundle', 'mybundle')
-&gt;fieldCondition('field_terms', 'tid', $termid)

$result = $query-&gt;execute();
$nid = array_keys($result['node'])-&gt;nid;
print $nid;
?&gt;


The problem is that no matter I do, I am not getting nid output. Can anybody help? Thank you.
array_keys($result['node']) isn't going to return an object that you can select a nid property from; it's going to return an array of nids that have $termid tagged in its field_terms field. If you're just looking for the first nid in the query results you can do $nid = array_keys($result['node'])[0];