On my site, I have venues, and reviews of the venues, related with an entity reference field. I'm creating a computed field to store the UID of the first person to create a review for each venue. To do so I've written the below query. Now, it works fine when I enter the simplified sql directly into PHPmyadmin, and substitute $entity->nid with an actual nid, but for some reason it just will not work when I add it into the computed code field, with the added
fetch portions. Any ideas?
if (!$entity->nid) node_save($entity); $entity_field['value'] = db_query ( SELECT entity_id FROM ( db_query ( SELECT * FROM field_data_field_review_venue_reference AS ReviewRow WHERE field_review_venue_reference_target_id = $entity->nid )->fetchrow() ) AS uid LIMIT 1 )->fetchfield();