function votingapi_select_votes in Voting API 6
Same name and namespace in other branches
- 6.2 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 keyes 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.)
Return value
An array of vote objects matching the criteria.
3 calls to votingapi_select_votes()
- votingapi_recalculate_results in ./
votingapi.module - Loads all votes for a given piece of content, then calculates and caches the aggregate vote results. This is only intended for modules that have assumed responsibility for the full voting cycle: the votingapi_set_vote() function recalculates…
- votingapi_select_single_vote_value in ./
votingapi.module - Simple wrapper function for votingapi_select_votes. Returns the value of the first vote matching the criteria passed in.
- votingapi_set_vote in ./
votingapi.module - Cast a vote on a particular piece of content. If a vote already exists, its value is changed. In most cases, this is the function that should be used by external modules.
File
- ./
votingapi.module, line 288
Code
function votingapi_select_votes($criteria = array()) {
if (!empty($criteria['vote_source'])) {
$criteria['timestamp'] = time() - variable_get('votingapi_anonymous_window', 3600);
}
$votes = array();
$result = _votingapi_query('vote', $criteria);
while ($vote = db_fetch_object($result)) {
$votes[] = $vote;
}
return $votes;
}