You are here

public function PartyQuery::fetchPids in Party 8.2

Same name and namespace in other branches
  1. 7 includes/party.extender.inc \PartyQuery::fetchPids()

Execute a special case where we want a list of party ids.

This is a shortcut method to select the party id, group by party id to remove any duplicates, execute and return an array of pids.

Return value

array An array of party pids.

File

includes/party.extender.inc, line 375
Class to aid querying parties and attached entities.

Class

PartyQuery
Query extender for party attached entities.

Code

public function fetchPids() {

  // Make sure we're not selecting all fields from any tables.
  $tables =& $this
    ->getTables();
  foreach ($tables as &$table) {
    $table['all_fields'] = FALSE;
  }

  // Make sure we only select party.pid.
  $fields =& $this
    ->getFields();
  $fields = array(
    'pid' => array(
      'field' => 'pid',
      'table' => $this->base_alias,
      'alias' => 'pid',
    ),
  );

  // Make sure we only group by party.pid.
  $group_by =& $this
    ->getGroupBy();
  $group_by = drupal_map_assoc(array(
    "{$this->base_alias}.pid",
  ));

  // Execute and return our pids.
  $result = $this
    ->execute();
  return $result
    ->fetchCol();
}