Developer Center

Upgrades

It is important to publish module updates and upgrades.

If it is needed to modify the database structure of the modules or make a special setting in the files, a way to implement this is required.

When the configuration settings of related module are accessed after the update, upgrade function is called.

Sample Upgrade Function

An example of how you can use this function is shown below.

public function upgrade(){
    if($this->config["meta"]["version"] < 1.1)
    {
        /*
         * Modules::$init->db->query("ALTER TABLE md_SampleAddon ADD test1 varchar(255);"); # PDO::query()
        */
    }
    elseif($this->config["meta"]["version"] < 1.2)
    {
        /*
         * Modules::$init->db->query("ALTER TABLE md_SampleAddon ADD test2 varchar(255);"); # PDO::query()
        */
    }

    /*
     * If you want to give an error:
     * $this->error = "sample error text here";
     * return false;
    */

    return true;
}
Hooks

Do you have any questions?

Feel free to contact us
Contact Us
Copyright © 2024. All Rights Reserved.
Join Our Discord Channel
Top