}
/**
- * Delete a CiviCRM-table.
+ * Drop a table if it exists.
*
* @param string $tableName
- * Name of the table to be created.
+ * @throws \Civi\Core\Exception\DBQueryException
*/
- public static function dropTable($tableName) {
- $sql = "DROP TABLE $tableName";
+ public static function dropTable(string $tableName): void {
+ $sql = "DROP TABLE IF EXISTS $tableName";
CRM_Core_DAO::executeQuery($sql);
}
function civicrm_api3_custom_group_delete($params) {
$values = new CRM_Core_DAO_CustomGroup();
$values->id = $params['id'];
- $values->find(TRUE);
-
+ if (!$values->find(TRUE)) {
+ return civicrm_api3_create_error('Error while deleting custom group');
+ }
$result = CRM_Core_BAO_CustomGroup::deleteGroup($values, TRUE);
return $result ? civicrm_api3_create_success() : civicrm_api3_create_error('Error while deleting custom group');
}