votingapi_select_results

  1. drupal
    1. 6 votingapi.module function
    2. 7 votingapi.module function
Drupal 7 votingapi_select_results($criteria = array(), $limit = 0)

Select cached vote results from the database.

Parameters

$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_cache_id'] (If this is set, all other keys are skipped) $criteria['entity_id'] $criteria['entity_type'] $criteria['value_type'] $criteria['tag'] $criteria['function'] $criteria['timestamp'] (If this is set, records with timestamps GREATER THAN the set value will be selected.)

$limit: An optional integer specifying the maximum number of votes to return.

Return value

An array of vote results matching the criteria.

2 calls to votingapi_select_results()

File

sites/all/modules/votingapi/votingapi.module, line 377
A generalized voting API for Drupal.

Code

function votingapi_select_results($criteria = array(), $limit = 0) {
  $query = db_select('votingapi_cache')->fields('votingapi_cache');
  foreach ($criteria as $key => $value) {
    $query->condition($key, $value, is_array($value) ? 'IN' : '=');
  }
  if (!empty($limit)) {
    $query->range(0, $limit);
  }
  return $query->execute()->fetchAll(PDO::FETCH_ASSOC);
}