You are here

function flag_flag::_update_count in Flag 5

Same name and namespace in other branches
  1. 6 flag.inc \flag_flag::_update_count()

Updates the flag count for this content

@private

2 calls to flag_flag::_update_count()
flag_flag::_flag in ./flag.inc
A low-level method to flag content.
flag_flag::_unflag in ./flag.inc
A low-level method to unflag content.

File

./flag.inc, line 480
Implements various flags. Uses object oriented style inspired by that of Views 2.

Class

flag_flag
This abstract class represents a flag, or, in Views 2 terminology, "a handler".

Code

function _update_count($content_id) {
  $count = db_result(db_query("SELECT COUNT(*) FROM {flag_content} WHERE fid = %d AND content_id = %d", $this->fid, $content_id));
  $result = db_query("UPDATE {flag_counts} SET count = %d WHERE fid = %d AND content_id = %d", $count, $this->fid, $content_id);
  if (!db_affected_rows()) {
    db_query("INSERT INTO {flag_counts} (fid, content_type, content_id, count) VALUES (%d, '%s', %d, %d)", $this->fid, $this->content_type, $content_id, $count);
  }
}