What does the votingapi_set_votes function in the votingapi module actually do? I am trying to use the Voting API module to add a vote through a menu item. Meaning that when someone visits a menu item [the/menu/item] a vote is added to the database.

There is already the Voting API functions that does that. I don't understand what the votingapi_set_votes function in the Voting API module does.

I have read the website documentation however I don't understand what it does and how can I use it. And couldn't find an example of usage either.

I have tried the follwing to add a vote: 

  $items['the/menu/path/1'] = array
  (
  'title' =&gt; 'Some title',
  'page callback' =&gt; 'my_page',
  'access callback' =&gt; TRUE
);

return $items;
}

function my_page(){

  $votes = array();
  $votes[] = array(
    'content_type' =&gt; 'news',
    'content_id' =&gt; 1025,
    'value_type' =&gt; 'points',
    'value' =&gt; '1',
  );

  $criteria = array(
    'content_type' =&gt; 'news',
    'content_id' =&gt; 1025,
    'function' =&gt; 'sum',
    'value_type' =&gt; 'points',
  );


  if (TRUE) {
    if (module_exists('votingapi')) {
      // die("test");
      votingapi_set_votes($votes);
      die();
      $result = (votingapi_select_results($criteria));
      print 'result is: '.$result[0][value];
      $result = '';
    }
  }
  return "true";
}


But it gives me an SQL error like so:


  PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column
  'content_type' in 'where clause': SELECT votingapi_vote.* FROM
  {votingapi_vote} votingapi_vote WHERE (content_type =
  :db_condition_placeholder_0) AND (content_id =
  :db_condition_placeholder_1) AND (value_type =
  :db_condition_placeholder_2) AND (uid = :db_condition_placeholder_3) ;
  Array ( [:db_condition_placeholder_0] => news
  [:db_condition_placeholder_1] => 1025 [:db_condition_placeholder_2] =>
  points [:db_condition_placeholder_3] => 130 ) in
  votingapi_votingapi_storage_select_votes() (line 225 of
  C:\Users\tarek.ismail\public\egyptinnovate\sites\all\modules\contrib\votingapi\votingapi.module).
Here is a working example:

function YourModule_menu(){
  $items = array();
  $items['the/menu/path/1'] = array
    (
    'title' =&gt; 'Voting button',
    'page callback' =&gt; '_YourModule_voting',
    'access callback' =&gt; TRUE
    'type' =&gt; MENU_CALLBACK,

    );
  return $items;
}

function _YourModule_voting(){
  $nid=arg(3);
  $votes = array(
    'entity_type' =&gt; 'node',
    'entity_id' =&gt; $nid,
    'value_type' =&gt; "points",
    'value' =&gt; 1,
    'tag' =&gt; "like",
    );

  $criteria = NULL;

  if (module_exists('votingapi')) {
      votingapi_set_votes($votes);
  }     

  return "true";
}