You are here

function sf_prematch_match_by_load in Salesforce Suite 7

Same name and namespace in other branches
  1. 6.2 sf_prematch/sf_prematch.module \sf_prematch_match_by_load()
  2. 7.2 sf_prematch/sf_prematch.module \sf_prematch_match_by_load()

Loads a prematch from the database.

Parameters

$fieldmap: The index of the fieldmap's prematch to load.

Return value

An array containing the prematch rule.

3 calls to sf_prematch_match_by_load()
sf_prematch_delete_form in sf_prematch/sf_prematch.admin.inc
sf_prematch_edit_form in sf_prematch/sf_prematch.admin.inc
sf_prematch_sf_find_match in sf_prematch/sf_prematch.module
Implement hook_sf_find_match

File

sf_prematch/sf_prematch.module, line 95
Extends Salesforce API module so checks for an existing match for an object before creating a new one.

Code

function sf_prematch_match_by_load($fieldmap) {
  static $match_bys;
  if (!isset($match_bys[$fieldmap]) && $fieldmap != '') {
    $result = db_query("SELECT * FROM {salesforce_prematch} WHERE fieldmap = %d", $fieldmap);
    $match_by = db_fetch_array($result);
    if (count($match_by)) {
      $match_bys[$fieldmap] = $match_by;
    }
    else {
      $match_bys[0] = array(
        'fieldmap' => $fieldmap,
        'primary_field' => '',
        'secondary_field' => '',
        'tertiary_field' => '',
        'rule' => 1,
      );
      $fieldmap = 0;
    }
  }
  return $match_bys[$fieldmap];
}