You are here

function field_file_references in FileField 6.2

Same name and namespace in other branches
  1. 6.3 field_file.inc \field_file_references()

return references to a file by a single field.

1 call to field_file_references()
filefield_file_references in ./filefield.module
Implementation of hook_file(). (Which is implemented by filefield/imagefield in Drupal 6 yet).

File

./field_file.inc, line 275
Common functionality for file handling CCK field modules.

Code

function field_file_references($file, $field) {
  $db_info = content_database_info($field);
  $references += db_result(db_query('SELECT count(' . $db_info['columns']['fid']['column'] . ')
      FROM {' . $db_info['table'] . '}
      WHERE ' . $db_info['columns']['fid']['column'] . ' = %d', $file->fid));
  if (isset($file->field_name) && $field['field_name'] == $file->field_name) {
    --$references;

    // doesn't count as it's being deleted
  }
  return $references;
}