You are here

function hook_votingapi_storage_select_votes in Voting API 7.2

Select invidual votes from the database

Parameters

array $criteria: A keyed array used to build the select query. Keys can contain a single value or an array of values to be matched. $criteria['vote_id'] (If this is set, all other keys are skipped) $criteria['entity_id'] $criteria['entity_type'] $criteria['value_type'] $criteria['tag'] $criteria['uid'] $criteria['vote_source'] $criteria['timestamp'] If this is set, records with timestamps GREATER THAN the set value will be selected. Defaults to REQUEST_TIME - variable_get('votingapi_anonymous_window', 3600); if the anonymous window is above zero.

int $limit: An integer specifying the maximum number of votes to return. 0 means unlimited and is the default.

Return value

array An array of votes matching the criteria.

1 function implements hook_votingapi_storage_select_votes()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

votingapi_votingapi_storage_select_votes in ./votingapi.module
Implements of hook_votingapi_storage_select_votes().

File

./votingapi.api.php, line 174
Provides hook documentation for the VotingAPI module.

Code

function hook_votingapi_storage_select_votes($criteria, $limit) {
  _mongodb_votingapi_prepare_vote($criteria);
  $find = array();
  foreach ($criteria as $key => $value) {
    $find[$key] = is_array($value) ? array(
      '$in' => $value,
    ) : $value;
  }
  $cursor = mongodb_collection('votingapi_vote')
    ->find($find);
  if (!empty($limit)) {
    $cursor
      ->limit($limit);
  }
  $votes = array();
  foreach ($cursor as $vote) {
    $votes[] = $vote;
  }
  return $votes;
}