Databases: how to add new table

Databases: how to add new table

by Ye Chen -
Number of replies: 2

Once I created install.xml, it would work when you first time installed your module, how about later you need to create a new table? which function in moodle I can use to create new table, I did not find it in ddllib.php and dmllib.php. Maybe I missed it.

Any one can tell?

Thanks

Ye

Average of ratings: -
In reply to Ye Chen

Re: Databases: how to add new table

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
upgrade.php, in the same folder as install.xml.

If you use Admin -> misc -> XMLDB Editor, then that will generate the code to go into upgrade.php, as well as upgrading the install.xml file.
In reply to Tim Hunt

Re: Databases: how to add new table

by Ye Chen -

I tried to use XMLDB Editor to update my install.xml.

This is how I did and got stucked.

1. Go to XMLDB Editor

2. choose the module I need to modified, click Load, then the load link is deactive, Edit and Unload is active.

3. Click Edit, I did all the edit and create new tables. Then I got stucked here. I could not find anywhere I can save or generate the code to upgrade.php.  I can click view PHP code to view the code,

If I go back step 2 above, I only see the [Edit] link active, all other links to this module is deactive.

So my question is how I can use XMLDB Editor to save the generated code?

Another question is if it generates the code to upgrade.php, how this file will be called and executed?

Thanks

Ye