You are here

function VotingApi_ResultCriteria::select in Voting API 7.3

Select cached vote results from the database.

Parameters

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

Return value

An array of vote results matching the criteria.

1 call to VotingApi_ResultCriteria::select()
VotingApi_ResultCriteria::singleValue in ./votingapi.module
Retrieve the value of the first result matching the criteria.

File

./votingapi.module, line 228
A generalized voting API for Drupal.

Class

VotingApi_ResultCriteria
Criteria to select VotingApi_Results

Code

function select($limit = 0) {
  $query = db_select('votingapi_cache')
    ->fields('votingapi_cache');
  $this
    ->addConditions($query);
  if (!empty($limit)) {
    $query
      ->range(0, $limit);
  }
  $result = $query
    ->execute();
  $result->fetchOptions['class_name'] = 'VotingApi_Result';
  return $result
    ->fetchAll(PDO::FETCH_CLASS);
}