I'm working on a project where I have 2 Drupal installations which occasionally need to interact with eachothers database.

So far, I've been able to set up all interactions using db_set_active and db_select/db_query/db_update statements (example below):


Simple select queries don't pose any problem. And while update queries are being propagated correctly, they have an inherit issue: they don't call the save hooks in the target Drupal installation...

My use case: I'm database updating a boolean CCK field (in Drupal B) from 0 to 1 (through a module script at Drupal A) and Rules (at Drupal B) should trigger on this. Moreover, the field caches aren't cleared so probably going directly through the database isn't a very good way to update the field...

Any other ideas how to update fields from within external scripts? Or maybe how to execute Rules while keeping the database operations?


  • Have you tried using Entity API? drupal.org/node/1842304
    – pgrujic
    Sep 4, 2013 at 20:49
  • Interacting directly with another site's database sounds dangerous. What is it you're trying to do with the boolean value?
    – beth
    Sep 4, 2013 at 22:58
  • Hi Beth, I'm updating a boolean CCK field of a content type (like: 'Contract Signed?'). It really isn't that dangerous as Drupal has built-in support for this. However as the question states: direct database updates (using sql UPDATE ... SET ...) omit all various Drupal hooks which I do need. Sep 5, 2013 at 6:56
  • @pgrujic I can succesfully read values using Entity API, but updating fields in the database (through entity_metadata_wrapper or entity_save) still fails with an error (EntityMetadataWrapperException: Unknown data property field_*****) Sep 5, 2013 at 7:37

1 Answer 1


I have achieved the similar functionality with following code. I worked on Drupal 6. But, hopefully it worked for you.

I have two same drupal installation and when creating new node in one installation, I need to create node into another Drupal installation also. So, I customize the node form and added a submit function to node form.

Custom Submit function

function custom_node_export_form_submit($form, $form_state) {

  //Creating node object
  $node = new stdClass;

  foreach ($form_state['values'] as $key => $value) {
    $node->$key = $value;    





Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.