How to edit DB values with Ad-Hoc Reports or Configurable Reports

How to edit DB values with Ad-Hoc Reports or Configurable Reports

by Kimber Warden -
Number of replies: 6

Is there something I can tweak in either the Configurable Reports block or the Ad-Hoc Reports plug-in so that I can edit database tables? I know there are risks involved in editing the database tables this way, but I have permissions locked down so that I'm the only one that can write SQL queries, and it's the only hope I have of being able to change the value of a particular cell in a particular table. My not-very-helpful host won't allow me to access my own database, even though I am the sole Moodle administrator. I need an alternative solution. Thanks for any help!


Kimber

Average of ratings: -
In reply to Kimber Warden

Re: How to edit DB values with Ad-Hoc Reports or Configurable Reports

by Johannes Burk -
Picture of Core developers Picture of Plugin developers

I'm not sure I understand you correctly. You can't access the database directly (command line or web interface) but you have (write) access to the web dir?

Then you can write a PHP file and either use the plain php functions for your database engine or use the moodle data manipulation api: https://docs.moodle.org/dev/Data_manipulation_API


In reply to Johannes Burk

Re: How to edit DB values with Ad-Hoc Reports or Configurable Reports

by Kimber Warden -

That's correct. I can't access the /moodledata/ folder which contains the database, but I CAN access the /moodle/ folder and edit Moodle web pages to my heart's content. Using one of the report plug ins, I can at least query the database, but they prevent me from updating it. I get the error "Not allowed words" when I write:

UPDATE TABLE prefix_assign_grades

SET grade="0.00"

WHERE id="13828"

Thanks for pointing out the Data manipulation api. I wasn't aware of it. I don't know how to use it, either, but at least I have a place to start from. Any hints on how I'd go about writing the above query?

In reply to Kimber Warden

Re: How to edit DB values with Ad-Hoc Reports or Configurable Reports

by Darko Miletić -

This is the wrong way of approaching the problem. You do have username and password for database access? (You must since you have moodle working with it)

Install phpmyadmin and use those credentials to access your database.


In reply to Darko Miletić

Re: How to edit DB values with Ad-Hoc Reports or Configurable Reports

by Kimber Warden -

No, I don't have a database username and password. My host set it up.

In reply to Kimber Warden

Re: How to edit DB values with Ad-Hoc Reports or Configurable Reports

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

No.

If you want an admin interface that lets you edit the DB contents, try this plugin: https://moodle.org/plugins/view/local_adminer

In reply to Tim Hunt

Re: How to edit DB values with Ad-Hoc Reports or Configurable Reports

by Kimber Warden -

Oh my gosh, I had no idea that plugin existed! It worked! You're a lifesaver, Tim!!!