0

I am working with Moodle and I am trying to export a series of MySQL tables from a Moodle installation to an Excel file, I know that Moodle works under PHP, but I understand that the PHP it uses is different from ordinary PHP, or am I wrong?

Moodle version 3.11

Thanks for your help, I'm sorry I don't have code, I'm new to this world and I had to start with Moodle

  • PHP is langugae and it is same for moodle as well. If you need ddatabase table, then export through database interface directly. – developerCK Jul 20 '21 at 09:44
  • @developerCK Ok apparently it is a small detail that I forgot to mention, as it turns out that I need to grant the user the possibility of downloading the table with a button, but it is independent of the option offered by Moodle – Alfredo Imanol Jul 20 '21 at 16:12

1 Answers1

0

There are a few options to export the rows of your moodle tables into the excel/CSV files: Uses the syntax of SELECT INTO files and runs the script in the database server. Example:

1 SELECT id,name,value
2 FROM config
3 INTO OUTFILE '/var/lib/mysql-files/config.csv'
4 FIELDS TERMINATED BY ','
5 ENCLOSED BY '"'
6 LINES TERMINATED BY '\n';

Please ensure the user of the database has access to the moodle tables and you can check the accessible directory to write in the parameter secure_file_priv using the following command:

1 mysql> show global variables like 'secure_file_priv';
2 +------------------+-----------------------+
3 | Variable_name    | Value                 |
4 +------------------+-----------------------+
5 | secure_file_priv | /var/lib/mysql-files/ |
6 +------------------+-----------------------+
7 1 row in set (0.00 sec) 

Uses third-party database GUI (eg: DBEaver, Heidi SQL, Navicat). Usually, they provide the export feature to the CSV files as well.

Severalnines
  • 106
  • 5