Contributions API

path_redirect_delete

Definition

path_redirect_delete($from = NULL, $to = NULL, $rid = NULL)
contributions/path_redirect/path_redirect.module, line 173

Description

Delete the specified path redirect. This will delete as specifically as possible, in order: by $rid, by ($from, $to), by $from, or by $to. Multiple redirects may be deleted if the $to parameter matches more than one entry.

This function is part of an API available for external code to use.

Parameters

$from Source path of redirect to delete.

$to Destination path or URL of redirect to delete.

$rid Unique ID of redirect to delete.

Return value

The result of the deletion query.

Code

<?php
function path_redirect_delete($from = NULL, $to = NULL, $rid = NULL) {
  if (!empty($rid)) {
    $result = db_query("DELETE FROM {path_redirect} WHERE rid = %d", $rid);
  }
  else if (!empty($from)) {
    if (!empty($to)) {
      $result = db_query("DELETE FROM {path_redirect} WHERE path = '%s' AND redirect = '%s'", $from, $to);
    }
    else {
      $result = db_query("DELETE FROM {path_redirect} WHERE path = '%s'", $from);
    }
  }
  else if (!empty($to)) {
    $result = db_query("DELETE FROM {path_redirect} WHERE redirect = '%s'", $to);
  }
  return $result;
}
?>