Error in query : Call to a member function execute() My query return me an error.
I have the gid of a organic group.
I want to retrieve the last news for this group.

 $query = db_select('node','n');
 $result = $query
 -&gt;fields('n')
 -&gt;condition('type','news','=')
 -&gt;join('field_data_group_audience','fdga','n.nid = fdga.entity_id AND fdga.group_audience_gid = :gid', array(':gid' =&gt; $gid))
 -&gt;execute();


This query give me a : Fatal error: Call to a member function execute() on a non-object

Thanks
The join() method doesn't return the query object, so can't be used in a chain like you're currently doing. You'll need to do something like this instead:

$query = db_select('node','n');
  -&gt;fields('n')
  -&gt;condition('type','news','=');

$query-&gt;join('field_data_group_audience','fdga','n.nid = fdga.entity_id AND fdga.group_audience_gid = :gid', array(':gid' =&gt; $gid));

$result = $query-&gt;execute();