You are here

function _votingapi_delete_votes_by_entity in Voting API 7.2

Helper function to delete all votes on given entities.

Parameters

array entity ids:

string entity type:

2 calls to _votingapi_delete_votes_by_entity()
votingapi_entity_delete in ./votingapi.module
Implements hook_entity_delete().
_votingapi_cron_delete_orphaned in ./votingapi.module
Delete votes and cache entries for a number of entities in the queue.

File

./votingapi.module, line 721
A generalized voting API for Drupal.

Code

function _votingapi_delete_votes_by_entity($entity_ids, $type) {
  $result = db_select('votingapi_vote', 'v')
    ->fields('v', array(
    'vote_id',
    'entity_type',
    'entity_id',
  ))
    ->condition('entity_type', $type)
    ->condition('entity_id', $entity_ids)
    ->execute();
  $votes = array();
  foreach ($result as $row) {
    $votes[] = (array) $row;
  }
  votingapi_delete_votes($votes);
}