I've discovered that:
$file = get_record_by_id("file", $fileid)
works ONLY for files that belong to items that are referenced to in omeka_items table, i.e. those files whose item_id has a corresponding id in omeka_items.
I am sure this is done for a good reason, but in my worfklow I need to create file objects based on ids for "orphaned" files, i.e. those files who's item no longer exists. How can I do that?
Or to put the same question slightly differently: if I start with:
$sql = "select * from omeka_files where item_id not in (select id from omeka_items)";
$result = get_db()->fetchAll($sql);
how can I covert my database rows into proper file objects (so that I can do file_markup($file) with them... ?