| Versionen | |
|---|---|
| drupal7 | file_load_multiple($fids = array(), $conditions = array()) |
Load file objects from the database.
see hook_file_load()
$fids An array of file IDs.
$conditions An array of conditions to match against the {files} table. These should be supplied in the form array('field_name' => 'field_value').
An array of file objects, indexed by fid.
includes/
<?php
function file_load_multiple($fids = array(), $conditions = array()) {
$query = db_select('files', 'f')->fields('f');
// If the $fids array is populated, add those to the query.
if ($fids) {
$query->condition('f.fid', $fids, 'IN');
}
// If the conditions array is populated, add those to the query.
if ($conditions) {
foreach ($conditions as $field => $value) {
$query->condition('f.' . $field, $value);
}
}
$files = $query->execute()->fetchAllAssoc('fid');
// Invoke hook_file_load() on the terms loaded from the database
// and add them to the static cache.
if (!empty($files)) {
foreach (module_implements('file_load') as $module) {
$function = $module . '_file_load';
$function($files);
}
}
return $files;
}
?>
Kommentare
Kommentar hinzufügen