/** * Issues a db_query() against the CiviCRM database. */ function civicrm_db_query($query) { global $db_url; // normally Drupal's DSN. $original_url = $db_url; // we'll save it off temporarily. $db_url = CIVICRM_DSN; // set it to the CiviCRM DSN. db_set_active('civicrm'); // then make CiviCRM active. $args = func_get_args(); // load all the args passed. array_shift($args); // shove off the SQL query. $result = db_query($query, $args); // make the query against CiviCRM. $db_url = $original_url; // toggle back to Drupal's DSN. db_set_active('default'); // and make that active again. return $result; // return CiviCRM database result. }