You are here

function votingapi_add_results in Voting API 6

Same name and namespace in other branches
  1. 6.2 votingapi.module \votingapi_add_results()
  2. 7.2 votingapi.module \votingapi_add_results()

Save a single vote result to the database.

Parameters

robj: An array of vote result objects with the following properties: $robj->content_type $robj->content_id $robj->value_type $robj->value $robj->tag $robj->function $robj->timestamp (Optional, defaults to time())

1 call to votingapi_add_results()
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 223

Code

function votingapi_add_results($vote_results = array()) {
  if (is_object($vote_results)) {
    $vote_results = array(
      $vote_results,
    );
  }
  foreach ($vote_results as $robj) {
    $robj->timestamp = time();
    db_query("INSERT INTO {votingapi_cache} (content_type, content_id, value, value_type, tag, function, timestamp) VALUES ('%s', %d, %f, '%s', '%s', '%s', %d)", $robj->content_type, $robj->content_id, $robj->value, $robj->value_type, $robj->tag, $robj->function, $robj->timestamp);
  }
}