You are here

function votingapi_get_vote in Voting API 5

A simple helper function that returns a single vote record.

Parameters

$content_type: A string identifying the type of content whose votes are being retrieved. Node, comment, aggregator item, etc.

$content_id: The key ID of the content whose votes are being retrieved.

$value_type: An optional int representing the type of value saved in the vote. Three standard types are defined by votingapi: 'percent' -- 'Value' is a number from 0-100. The API will cache an average for all votes. 'points' -- 'Value' is a positive or negative int. The API will cache the sum of all votes. 'option' -- 'Value' is an int representing a specific option. The API will cache a vote-count for each option.

$tag: A string to separate multiple voting criteria. For example, a voting system that rates software for 'stability' and 'features' would cast two votes, each with a different tag. If none is specified, the default 'vote' tag is used.

$uid: A string to indicate the aggregate function being retrieved (average, count, max, etc)

Return value

A single vote object.

File

./votingapi.module, line 354

Code

function votingapi_get_vote($content_type, $content_id, $value_type, $tag, $uid) {
  $result = db_query("SELECT * FROM {votingapi_vote} v WHERE content_type='%s' AND content_id=%d AND value_type='%s' AND tag='%s' AND uid=%d", $content_type, $content_id, $value_type, $tag, $uid);
  $vote = db_fetch_object($result);
  return $vote;
}