mdl_files itemid relation to an activity

mdl_files itemid relation to an activity

by anoop kumar -
Number of replies: 1
Consider an activity/resource which is having a file_upload. I could see files are added to mdl_files tables and according to my knowledge, the itemid is the field that specifies, to which activity/resource instance the file is related to. But after upload in user-context, i could see the same file details are added again to the mdl_files table with coursemodule context and itemid as 0. My doubt is, how does these file id's or itemids actually related to an activity/resource instance? and is there any built-in function to get these itemid's for an activity(the one in user context)

Any help is appreciated..
Average of ratings: -
In reply to anoop kumar

Re: mdl_files itemid relation to an activity

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

The itemid does not necessarily relate to an activity or resource. What it means depends on where the file was uploaded.

Look instead at the contextid and component columns. They may tell you want you want to know. However, you really need to read the File API docs: https://docs.moodle.org/dev/File_API