function flag_flag::_increase_count in Flag 7.3
Same name and namespace in other branches
- 6.2 flag.inc \flag_flag::_increase_count()
- 7.2 flag.inc \flag_flag::_increase_count()
Increases the flag count for an object and clears the static counts cache.
@private
Parameters
int $entity_id: For which item should the count be increased.
int $number: The amount of counts to increasing. Defaults to 1.
1 call to flag_flag::_increase_count()
- flag_flag::flagging_insert in includes/
flag/ flag_flag.inc - Create a new Flagging to flag an entity.
File
- includes/
flag/ flag_flag.inc, line 1074 - Contains the flag_flag class. Flag type classes use an 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 _increase_count($entity_id, $number = 1) {
db_merge('flag_counts')
->key(array(
'fid' => $this->fid,
'entity_id' => $entity_id,
))
->fields(array(
'entity_type' => $this->entity_type,
'count' => $number,
'last_updated' => REQUEST_TIME,
))
->updateFields(array(
'last_updated' => REQUEST_TIME,
))
->expression('count', 'count + :inc', array(
':inc' => $number,
))
->execute();
// Reset the static cache of flag counts, so code running after this gets
// correct counts.
drupal_static_reset('flag_get_counts');
drupal_static_reset('flag_get_flag_counts');
}