You are here

function purl_delete in Persistent URL 7

Same name and namespace in other branches
  1. 6 purl.module \purl_delete()

Delete a modifier entry from the database.

File

./purl.module, line 584

Code

function purl_delete($modifier) {
  if (!empty($modifier['value'])) {
    $param = 'value';
    $where = $modifier['value'];
  }
  else {
    if (!empty($modifier['id'])) {
      $param = 'id';
      $where = $modifier['id'];
    }
  }
  $check = db_query("SELECT id FROM {purl} WHERE provider = :provider AND {$param} = :param", array(
    ':provider' => $modifier['provider'],
    ':param' => $where,
  ))
    ->fetchField();
  if ($check) {

    //TODO change this to the new db_delete() method
    $status = db_query("DELETE FROM {purl} WHERE provider = :provider AND {$param} = :param", array(
      ':provider' => $modifier['provider'],
      ':param' => $where,
    ));
    purl_load(NULL, TRUE);
    purl_modifiers(NULL, TRUE);
    return $status;
  }
  return FALSE;
}