Entity API

Using Entity Metadata Wrapper

The Entity API provides wrapper classes you may use to make dealing with the values of an entities properties and fields easier. Wrappers make it easier to get and set the values of fields and properties as well as to programmatically retrieve additional information about these elements and iterate over lists of values in a consistent manner.

This implies that one need not worry about fetching a node property in the format:
$node->field_name['und'][0]['value']  

Programmatically creating/deleting/modifying field-collection

Enough Said , visit the link: http://rajanmayekar.com/blog/programmatically-creating-deleting-modifyin...

One change wrt to deleting Field Collections is as follows:

<?php
$node
= node_load($node_id);
$field_collection_item_value = array();
foreach (
$node->field_collection_field[LANGUAGE_NONE] as $key => $value) {
   
$field_collection_item_value[] = $value['value'];
}
entity_delete_multiple('field_collection_item', array($field_collection_item_value));
?>