protected function PartyAcquisition::buildQuery in Party 7
Build the query for finding a party.
Parameters
array $values: An array of party fields to match on. Keys are the field and values are the expected values.
Return value
SelectQuery A query primed to return the party pids.
1 call to PartyAcquisition::buildQuery()
- PartyAcquisition::findMatch in includes/
party.acquisition.inc - Find a match for the given parameters.
File
- includes/
party.acquisition.inc, line 234 - Base classes for acquisition processes.
Class
- PartyAcquisition
- Base class for acquiring parties.
Code
protected function buildQuery(array $values) {
// Get our base query.
$query = db_select('party');
$query
->addField('party', 'pid');
// Add our matching conditions based on the context.
$match = $this->context['operator'] == 'OR' ? db_or() : db_and();
foreach ($values as $property => $value) {
$match
->condition("party.{$property}", $value);
}
$query
->condition($match);
// We never want to match to hidden parties.
$query
->condition('party.hidden', 0);
// Allow modules to alter the query.
$args = array(
&$query,
);
$this
->invoke('query_alter', $args);
return $query;
}