You are here

function reviews_update_review_count_for_node in Reviews 7

Helper function to update the review count table for a node.

4 calls to reviews_update_review_count_for_node()
reviews_add_review_submit in includes/reviews.pages.inc
Submit handler for reviews_add_review form.
reviews_approve_review in includes/reviews.admin.inc
Function for menu callback to approve a review.
reviews_edit_review_submit in includes/reviews.pages.inc
Submit handler for reviews_edit_review form.
reviews_list_confirm_delete_submit in includes/reviews.admin.inc
This function deletes the selected reviews.

File

includes/reviews.api.inc, line 146
This file contains API functions for the reviews system.

Code

function reviews_update_review_count_for_node($nid) {
  db_delete('reviews_count')
    ->condition('nid', $nid, '=')
    ->execute();
  $result = db_select('reviews', 'r')
    ->fields('r', array(
    'nid',
  ))
    ->condition('nid', $nid, '=')
    ->execute()
    ->fetchAll();
  $result2 = db_insert('reviews_count')
    ->fields(array(
    'nid' => $nid,
    'count' => count($result),
  ))
    ->execute();
}