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_comment 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 ...

Get PrestaShop Module Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.