In my module, I was trying to make use of db_or() in this way...

$filterSparten = db_select($this->tbl_hat_sparte, 'hs')
  ->fields('hs', array('hat_AID'));

$or = db_or();

foreach($_GET['tags'] as $tag) {
  $or->condition('hat_KID', $tag);


...which, unfortunately, only returns a SelectQuery-object:

SelectQuery Object
    [fields:protected] => Array
            [hat_AID] => Array

Why doesn't my code return a fetched results-object? I have compared it several times with the examples on the Drupal-pages, but I can't help myself with it.

  • No, I was not asking how to use db_or, but why it returns a SelectQuery-object, not a results-object?! – Hotte Unzensiert Limitiert Nov 28 '15 at 15:42
  • where you put this code? and when you try it wihout db_or is it return correctly? – Yusef Nov 28 '15 at 17:44
  • What are you dumping here, exactly? You seem to never save what you fetch to any variable... – Mołot Dec 1 '15 at 6:28

Assuming an unchanged core codebase, and assuming you mean that your final line is returning a SelectQuery (not the db_or(), which returns a DatabaseCondition), the only way you could be seeing a SelectQuery is if you're inspecting the wrong variable, i.e. $filterSparten. The query will remain a query, you need to assign the results to something else:

$results = $filterSparten->condition($or)

Inspecting $results should give you what you're expecting.
