Index: biblio_handler_field_contributor.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/biblio/views/biblio_handler_field_contributor.inc,v retrieving revision 1.1.2.1 diff -u -p -r1.1.2.1 biblio_handler_field_contributor.inc --- biblio_handler_field_contributor.inc 3 Jun 2009 19:39:41 -0000 1.1.2.1 +++ biblio_handler_field_contributor.inc 15 Jun 2009 14:43:02 -0000 @@ -40,14 +40,24 @@ class biblio_handler_field_contributor e $this->items = array(); foreach ($values as $result) { - $vids[] = $result->{$this->aliases['vid']}; + // Don't add empty results to the array. + if ($result->{$this->aliases['vid']} != '') { + $vids[] = $result->{$this->aliases['vid']}; + } } if (count($vids)) { + // Optimize query if $vids has only 1 item in the array, to use '=' instead of 'IN'. + if (count($vids) > 1){ + $vidstr = 'vid IN ('. implode(',', $vids) .')'; + } + else { + $vidstr = 'vid = '. $vids[0]; + } $result = db_query('SELECT * FROM {biblio_contributor} bc INNER JOIN {biblio_contributor_data} bcd ON bc.cid = bcd.cid - WHERE vid IN ('. implode(',', $vids) .')'. - ' AND auth_category='.$this->auth_category. + WHERE '. $vidstr . + ' AND auth_category='. $this->auth_category. ' ORDER BY bc.rank'); while ($item = db_fetch_array($result)) { // Clean up the $item from vid.