You are here

function salesforce_api_id_load in Salesforce Suite 6.2

Same name and namespace in other branches
  1. 5.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.

4 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().
_sf_node_export_cck_nodereference in sf_contrib/sf_contrib.module
_sf_node_export_cck_userreference in sf_contrib/sf_contrib.module

File

salesforce_api/salesforce_api.module, line 1097
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, name FROM {salesforce_object_map} WHERE drupal_type = '%s' AND oid = %d", $type, $id);

  // Return an empty array if no data was found.
  if (!($data = db_fetch_object($result))) {
    return (object) array(
      'sfid' => NULL,
      'name' => NULL,
    );
  }
  else {

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