Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

Using XMLDB

From MoodleDocs

(This page is in progress of writing and editing, intended for third-party module developers to help them switch to XMLDB.)


How XMLDB can help you

Everywhere in Moodle now use XMLDB. Created to prevent developer from creating custom database schemas for different database system. If you don't know what XMLDB is, You can learn more about it here XMLDB_introduction

In every module folder, there is db/ folder where database structure stored. The folder usually contains mysql.php, mysql.sql, etc for different database.

It's mean that you have to create different files for each database systems. If there are 5 database, you have to create 10 files (2 each). XMLDB is intended to solve this. Switching to XMLDB is very easy, save your time and effort by creating just 1 file.

Creating XMLDB files

XMLDB file in module is stored in db/ folder, named install.xml, You can use a built-in XMLDB editor to create or edit any install.xml files. If you're using MySQL as your default database schemes. XMLDB editor's powerful tools allowing retrofit MySQL table to XMLDB format.

Your XMLDB editor is located in administration block, go to Miscellaneous > XMLDB editor. You may unable to click on Create link and also can't edit your module. Since you must make your module folder has write permission first. In Linux operating system, chmod your module folder to 777 solves this. Now you're ready to create your module's XMLDB files.

More information about XMLDB editor.

Create install.xml

If you never create install.xml before (your db/ doesn't have install.xml), click Create first.

Retrofit MySQL table to XMLDB

First, your module has to be installed. Then follow these steps:

  1. Go to
  2. Find your module folder, be sure it is writeable
  3. Click Create, then click Load, you will get a page