You are here

function salesforce_api_id_load in Salesforce Suite 5.2

Same name and namespace in other branches
  1. 6.2 salesforce_api/salesforce_api.module \salesforce_api_id_load()
  2. 7 salesforce_api/salesforce_api.module \salesforce_api_id_load()
  3. 7.2 salesforce_api/salesforce_api.module \salesforce_api_id_load()

Loads the Salesforce ID and fieldmap index of a Drupal object.

Parameters

$type: The type of the Drupal object you are requesting data for; node or user.

$id: The associated unique ID used to identify the object in Drupal.

Return value

An array containing the associated Salesforce object type and ID or an empty array if no data was found.

2 calls to salesforce_api_id_load()
sf_node_nodeapi in sf_node/sf_node.module
Implementation of hook_nodeapi().
sf_user_user in sf_user/sf_user.module
Implementation of hook_user().

File

salesforce_api/salesforce_api.module, line 768
Defines an API that enables modules to interact with the Salesforce server.

Code

function salesforce_api_id_load($type, $id) {

  // Query the main ID table for the associated data.
  $result = db_query("SELECT sfid, fieldmap FROM {salesforce_ids} WHERE drupal_type = '%s' AND drupal_id = %d", $type, $id);

  // Return an empty array if no data was found.
  if (!($data = db_fetch_array($result))) {
    return array();
  }
  else {

    // Otherwise return the Salesforce object type and ID.
    return $data;
  }
}