Problem is in the title basically, I'm trying to update a specific field in my node and I have to do it by using drupal_write_record rather than loading and modifying the node object itself, or by using node_save etc, but my changes aren't being reflected until I flush the caches for the site.
Is there something I need to do to have Drupal immediately aware of the changes?
Code:
$next_delta = db_query('SELECT MAX(delta) + 1 AS del FROM {field_data_my_field} WHERE entity_id = :nid', array(':nid' => $nid))->fetchField();
$data = array(
'entity_type' => 'node',
'bundle' => $node->type,
'deleted' => 0,
'entity_id' => $node->nid,
'revision_id' => $node->vid,
'language' => LANGUAGE_NONE,
'delta' => $next_delta,
'field_my_data' => 1,
);
drupal_write_record('field_data_my_field', $data);
drupal_write_record('field_revision_my_data', $data);
I've tried adding entity_get_controller('node')->resetCache(array($node->nid));
into the code but that's not doing it either.