Fatal error: Call to a member function execute() on a non-object - db_select() addExpression I'm fixing up a module and I have the following db_select() code, but I'm getting the following error:


  Fatal error: Call to a member function execute() on a non-object in
  /var/www/xxx/sites/all/modules/xxx/xxx.module on line 414


I think it has something to do with the addExpression line, but I'm unsure of what this line does or what is the equivalent of addExpression in sql? What is MAX(poss), poss -- mean?

$query_poss = db_select('saved_lists', 'saved_lists')
  -&gt;condition('saved_lists.lid', $lid)
  -&gt;addExpression('MAX(poss)', 'poss')
  -&gt;execute()
  -&gt;fetchField();
The addExpression method returns the unique alias that was assigned for this expression, and thus cannot be chained.

Please look at this example and the document.

$q = db_select('parser_subtasks', 'st')
 -&gt;condition('QueueID', $task['ID'])
 -&gt;condition('IsDone', 0);
$q-&gt;addExpression('MIN(Delay)');
$min_time = $q-&gt;execute()-&gt;fetchField();