I am trying to figure out how to access the database activity programmatically.
I can't seem to be able to fin dhow Database activity is stored in Moodle. Whenever I search for it, I get the general database scheme.
Does anyone have a link? Also an code example how to access fields would be great.
Typically, any Moodle plugin database table uses its name prefixed with mdl_. In this case the main database activity table is, mdl_data. It also uses, mdl_data_content, mdl_data_fields, and mdl_data_records.
If you visit the Development tab at the top of this page, and then go to Core APis you will see Data manipulation API. There are many examples there.
Warning: It seems to me you plan on trying to directly manipulate the the data in the activity. If so, please try things on a development Moodle site and not on a production site.
thanks for the suggestions and clarifications.
I am indeed planning to hit the database directly. So, I am writing a desktop app and many times the users keeps some stuff in a Database activity on Moodle.
So, I was thinking to provide access to that activity directly from my app but after your comment and what I read I feel it is a bit risky and complicated.
Maybe I will pass.
What do you think?
Frankly, I would not. I think it is too much of a risk. Even using the built in database API while working on adding GDPR code to Hot Question a couple of weeks ago, I accidentally trashed my development Moodle, due to a misplace comma. Luckily, I had a recent backup.
yeah I though so; sounds risky to mess with tables and records. After all, in a real and commercial environment I can't be sure that I will be able to connect to the database directly.
Thanks for the help.