You are here

function purl_load in Persistent URL 6

Same name and namespace in other branches
  1. 7 purl.module \purl_load()

Load a modifier from the database by provider or value.

2 calls to purl_load()
purl_delete in ./purl.module
Delete a modifier entry from the database.
purl_save in ./purl.module
Save modifier to database. Will insert new entry if no ID is provided and update an existing one otherwise.

File

./purl.module, line 543

Code

function purl_load($modifier, $reset = FALSE) {
  static $cache;
  if (!isset($cache) || $reset) {
    $cache = array();
  }
  foreach (array(
    'id',
    'value',
  ) as $key) {
    if (isset($modifier['provider'], $modifier[$key])) {
      $provider = $modifier['provider'];
      $val = $modifier[$key];
      if (!isset($cache[$key][$provider][$val])) {
        $loaded = db_fetch_array(db_query("SELECT * FROM {purl} WHERE {$key} = '%s' AND provider = '%s'", $val, $provider));
        $cache[$key][$provider][$val] = $loaded;
      }
      return $cache[$key][$provider][$val];
    }
  }
  return FALSE;
}