How to remove all rows from a database table?
PermalinkHere's my current method that I'm using.
function delete(){ $db = Loader::db(); $db->query("DELETE * FROM tableName"); parent::delete(); }
I've also tried these two way without success:
function delete(){ $db = Loader::db(); $db->query("DROP TABLE tableName"); parent::delete(); }
function delete(){ $db = Loader::db(); $db->query("DELETE FROM tableName"); parent::delete(); }
None of these methods seem to work. What am I doing wrong here? All I want is to clean up the database when my block is removed.

Does the delete() function get called automatically when removing a block or do I have to call it manually somewhere?
For example, if you add a block to the first version of the page, and then go into a subsequent version and delete the block, the block is gone from that version of the page, but it's still around on the previous version of the page.
A good way to test whether this is working is to add a block to a page, make sure the data is in the table as you would expect, then delete the entire page.
After some more digging I see that I was looking for the uninstall event for the package.
Thanks though, that does clear up a lot of confusion as I thought delete fired when you removed the Block/Package in the backend.
another option is to install this add-on:http://www.concrete5.org/marketplace/addons/database-manager/...
You can then access your database and tables through the dashboard and remove it from there