You are here

function shurly_get_redirect in ShURLy 8

Same name and namespace in other branches
  1. 6 shurly.module \shurly_get_redirect()
  2. 7 shurly.module \shurly_get_redirect()

Given the short URL, return the long one NOTE: Always check $redirect->active before using the result

2 calls to shurly_get_redirect()
shurly_expand in ./shurly.module
Function to get the long url.
shurly_url_exists in ./shurly.module
Check to see if this short URL already exists.

File

./shurly.module, line 589
Description http://www.youtube.com/watch?v=Qo7qoonzTCE.

Code

function shurly_get_redirect($short_url, $check_active = FALSE) {
  $query = "SELECT * FROM {shurly} WHERE source = :short";
  if ($check_active) {
    $query .= ' AND active = 1';
  }
  $redirect = \Drupal::database()
    ->query($query, [
    'short' => $short_url,
  ])
    ->fetchObject();
  return $redirect;
}