function nodereference_count_update_count in Nodereference Count 6
Same name and namespace in other branches
- 7 nodereference_count.module \nodereference_count_update_count()
Update the count of nodereferences to a node when not updating via CCK.
Parameters
$field: the field array for this field instance
$nid: the nid of the node being referenced
$vid: the vid of the node being referenced
1 call to nodereference_count_update_count()
- nodereference_count_nodeapi in ./
nodereference_count.module - Implementation of hook_nodeapi().
File
- ./
nodereference_count.module, line 168 - Defines a field type for counting the references to a node.
Code
function nodereference_count_update_count($field, $nid, $vid = NULL) {
$vid = nodereference_count_get_vid($nid, $vid);
if (empty($vid)) {
return FALSE;
}
$count = nodereference_count_get_count($field, $nid);
$db_info = content_database_info($field);
$table = $db_info['table'];
$column = $db_info['columns']['value']['column'];
$update = new stdClass();
$update->vid = $vid;
$update->nid = $nid;
$update->{$column} = $count;
drupal_write_record($table, $update, 'vid');
content_clear_type_cache();
}