function _votingapi_insert_cache_result in Voting API 5
Insert a cached aggregate vote for a given piece of content.
Parameters
$content_type: A string identifying the type of content being rated. Node, comment, aggregator item, etc.
$content_id: The key ID of the content being rated.
$value: An int representing the aggregate value of the votes cast.
$value_type: An int representing the value_type shared by the aggregated votes.
$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.
$function: The summary function being used to aggregate the votes. 'sum', 'count', and 'average' are used by votingapi. If the value_type is 'option', this field contains the key. Slightly ugly, but oh well.
Return value
The resulting cached object.
1 call to _votingapi_insert_cache_result()
- 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…
File
- ./
votingapi.module, line 530
Code
function _votingapi_insert_cache_result($content_type, $content_id, $value, $value_type, $tag, $function) {
$vobj->vote_cache_id = db_next_id('{votingapi_cache}');
$vobj->content_type = $content_type;
$vobj->content_id = $content_id;
$vobj->value = $value;
$vobj->value_type = $value_type;
$vobj->tag = $tag;
$vobj->function = $function;
$vobj->timestamp = time();
db_query("INSERT INTO {votingapi_cache} (vote_cache_id, content_type, content_id, value, value_type, tag, function, timestamp) VALUES (%d, '%s', %d, %f, '%s', '%s', '%s', %d)", $vobj->vote_cache_id, $vobj->content_type, $vobj->content_id, $vobj->value, $vobj->value_type, $vobj->tag, $vobj->function, $vobj->timestamp);
return $vobj;
}