function votingapi_select_votes in Voting API 6.2
Same name and namespace in other branches
- 6 votingapi.module \votingapi_select_votes()
- 7.2 votingapi.module \votingapi_select_votes()
Select individual votes 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_id'] (If this is set, all other keys are skipped) $criteria['content_id'] $criteria['content_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.)
$limit: An optional integer specifying the maximum number of votes to return.
Return value
An array of votes matching the criteria.
2 calls to votingapi_select_votes()
- votingapi_select_single_vote_value in ./
votingapi.module - Retrieve the value of the first vote matching the criteria passed in.
- votingapi_set_votes in ./
votingapi.module - Cast a vote on a particular piece of content.
File
- ./
votingapi.module, line 337 - A generalized voting API for Drupal.
Code
function votingapi_select_votes($criteria = array(), $limit = 0) {
$anon_window = variable_get('votingapi_anonymous_window', 3600);
if (!empty($criteria['vote_source']) && $anon_window > 0) {
$criteria['timestamp'] = time() - $anon_window;
}
$votes = array();
$result = _votingapi_select('vote', $criteria, $limit);
while ($vote = db_fetch_array($result)) {
$votes[] = $vote;
}
return $votes;
}