| Versions | |
|---|---|
| 7 | file_usage_add(stdClass $file, $module, $type, $id, $count = 1) |
Records that a module is using a file.
This usage information will be queried during file_delete() to ensure that a file is not in use before it is physically removed from disk.
Examples:
$file A file object.
$module The name of the module using the file.
$type The type of the object that contains the referenced file.
$id The unique, numeric ID of the object containing the referenced file.
$count (optional) The number of references to add to the object. Defaults to 1.
drupal/
<?php
function file_usage_add(stdClass $file, $module, $type, $id, $count = 1) {
db_merge('file_usage')
->key(array(
'fid' => $file->fid,
'module' => $module,
'type' => $type,
'id' => $id,
))
->fields(array('count' => $count))
->expression('count', 'count + :count', array(':count' => $count))
->execute();
}
?>