I don't a way to get itemid in mdl_files when field filearea = draft
help me plz!
thanks
It is not at all clear what you are asking here.
If you want to find the itemid, then look in the field called 'itemid' (but a search for "filearea = 'draft'" will bring up a great many records, with a range of different itemids).
Please describe exactly what you are trying to do (including why you are not using the Moodle files API and are trying to access the mdl_files table directly) and someone may be able to tell you how to do it.
Thanks for your comment!
I want to get field itemid when field filearea = draft in mdl_files table
ex: filearea itemid
content 0
attachment id forum posts (in mdl_forum_posts table)
submission_file id assign submission (in mdl_assign_submission)
draft ?????????
how to get itemid when field filearea = draft ?
Files in the user draft id are only valid whilst a user is editing a form with a filemanager / editor present. A new draft itemid is generated at the point where file_prepare_draft_area is called to copy the files into the draft area when the form data is initialised. This draft item id is then passed back from the form (as a hidden element) and used to copy the files back out again by calling file_save_draft_area_files (there are also helper functions file_prepare_standard_XX and file_postupdate_standard_XX that wrap these and cover the most common cases).
So, to be clear, the draft item id is just a random number that is included within the form data at the point where it is used, and should never be needed outside of that form processing (draft areas are automatically deleted a few days after they were last used).