1

I want all the nodes of content type 'Site Address' attached to a group. I have written the following code. It doesn't seem to work.

$gid=$form_state['values']['group_id']; 
$query = db_select('node', 'n')
        ->condition('n.status', 1, '=')
        ->condition('n.type','site_address','=')
        ->fields('n', array('nid')); 
$query->join('og_membership', 'ogm', "ogm.gid = :gid AND n.nid = ogm.etid AND ogm.entity_type = 'node'  ", array(':gid' => $gid));   $result=$query->execute()->fetchAll();

dpm($result);
  • mistake in query AND n.nid = ogm.entity_id – Adi Sep 11 '15 at 6:33
  • There is no column named 'entity_id' in 'og_membership' table. – altaf raja Sep 11 '15 at 6:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.