programatically delete an event that has participants
You can delete participants from an event using:

civicrm_api3('Participant', 'delete', array(
  'event_id' =&gt; $v,
  'options' =&gt; array('match' =&gt; 'event_id')
));


Once that's done you can proceed to delete the event.