Deleting a table on uninstallation
The
uninstall
method is pretty much constructed the same way as the install
method.
First, create an uninstall.sql
file in the install
directory of your module in which you will write the following SQL command to drop the mymod_commen
t table:
DROP TABLE `PREFIX_mymod_comment`;
Next, in mymodcomment.php
, write an uninstall
method to do the following:
- Call the
uninstall
parent method - Load the
uninstall.sql
file - Check the return values
We will also delete the configuration values MYMOD_GRADES
and MYMOD_COMMENTS
. It isn't mandatory but it's cleaner that way.
At the end, you should have something like this:
public function uninstall() { // Call uninstall parent method if (!parent::uninstall()) return false; // Execute module install SQL statements $sql_file = dirname(__FILE__).'/install/uninstall.sql'; if (!$this->loadSQLFile($sql_file)) return false; // Delete configuration values Configuration::deleteByName('MYMOD_GRADES...