You are here

function taxonomy_machine_name_exists in Taxonomy Machine Name 7

Check to see if there is already a machine name used by a different term.

Parameters

string $machine_name: A machine name.

object $term: Current term.

Return value

bool TRUE if an machine name exists, FALSE if not.

1 call to taxonomy_machine_name_exists()
taxonomy_machine_name_uniquify in ./taxonomy_machine_name.module
Check and alter machine name to generate a unique value.

File

./taxonomy_machine_name.module, line 234

Code

function taxonomy_machine_name_exists($machine_name, $term) {
  $pid = db_query_range("SELECT tid\n     FROM {taxonomy_term_data}\n     WHERE vid = :vid\n       AND machine_name = :machine_name\n       AND tid <> :tid", 0, 1, array(
    ':vid' => $term->vid,
    ':machine_name' => $machine_name,
    ':tid' => isset($term->tid) ? $term->tid : 0,
  ))
    ->fetchField();
  return !empty($pid);
}