function delete() { //filter used in general $filter = new field_filter('categoryid', $this->id); //delete fields that belong to this category field::delete_records($filter, $this->_db); //delete the record associating the category to a context level field_category_contextlevel::delete_records($filter, $this->_db); //delete the actual category record parent::delete(); }