You are here

function taxonomy_get_terms_by_name_match in Slickgrid 7.2

Similar function to taxonomy_get_term_by_name, but allows for matching!

1 call to taxonomy_get_terms_by_name_match()
slickgrid_get_data in includes/slickgrid.getdata.inc
Return the data for a dynamically loaded SlickGrid.

File

includes/slickgrid.getdata.inc, line 269

Code

function taxonomy_get_terms_by_name_match($name, $vocabulary = NULL, $match = 'both') {
  switch ($match) {
    case 'both':
      $name = '%' . db_like(trim($name)) . '%';
      break;
    default:
      $name = db_like(trim($name)) . '%';
  }
  $query = db_select('taxonomy_term_data', 't')
    ->fields('t', array(
    'tid',
  ))
    ->condition('name', $name, 'LIKE');
  if (isset($vocabulary)) {
    $vocabulary = taxonomy_vocabulary_machine_name_load($vocabulary);
    $query
      ->condition('vid', $vocabulary->vid);
  }
  $tids = $query
    ->execute()
    ->fetchCol();
  if (count($tids)) {
    return taxonomy_term_load_multiple($tids);
  }
  else {
    return array(
      PHP_INT_MAX => PHP_INT_MAX,
    );
  }
}