You are here

function ARC_api::get_id in Taxonomy import/export via XML 5.2

Same name and namespace in other branches
  1. 5 arc/ARC_api.php \ARC_api::get_id()
  2. 6.2 arc/ARC_api.php \ARC_api::get_id()
  3. 6 arc/ARC_api.php \ARC_api::get_id()

File

arc/ARC_api.php, line 341

Class

ARC_api

Code

function get_id($val = "", $sql = false) {
  if (!isset($this->id_cache) || $this->id_cache_count > $this->api_val2id_cache_size) {
    $this->id_cache = array();
    $this->id_cache_count = 0;
  }
  $hash = sha1($val . ":" . $sql);
  if (!isset($this->id_cache[$hash])) {
    if (!($helper =& $this
      ->get_api_helper())) {
      return $this
        ->get_default_error();
    }
    $id_type = $this->config["id_type"];
    if ($id_type == "hash_int") {
      $this->id_cache[$hash] = $helper
        ->get_hash_int_id($val, $sql);
    }
    elseif ($id_type == "hash_md5") {
      $this->id_cache[$hash] = $helper
        ->get_hash_md5_id($val, $sql);
    }
    elseif ($id_type == "hash_sha1") {
      $this->id_cache[$hash] = $helper
        ->get_hash_sha1_id($val, $sql);
    }
    elseif ($id_type == "incr_int") {
      $this->id_cache[$hash] = $helper
        ->get_incr_int_id($val);
    }
    $this->id_cache_count++;
  }
  return $this->id_cache[$hash];
}