You are here

function taxonomy_csv_term_load_multiple in Taxonomy CSV import/export 6.3

Same name and namespace in other branches
  1. 6.5 taxonomy_csv.term.api.inc \taxonomy_csv_term_load_multiple()
  2. 6.2 taxonomy_csv.term.api.inc \taxonomy_csv_term_load_multiple()
  3. 6.4 taxonomy_csv.term.api.inc \taxonomy_csv_term_load_multiple()

Load multiple full terms.

This function can be used whenever to get more than one term from the database is needed. Terms have their links (parents, relations and synonyms).

Parameters

$tids: (Optional) An array of taxonomy term IDs.

$conditions: An array of conditions to add to the query. Currently managed conditions: vid and ascendant order.

Return value

An array of term objects eventually ordered.

2 calls to taxonomy_csv_term_load_multiple()
_taxonomy_csv_info_terms in import/taxonomy_csv.import.result.inc
Display stats and eventually lists of terms about imported terms.
_taxonomy_csv_vocabulary_export_process in export/taxonomy_csv.export.api.inc
Batch process of vocabulary export.

File

./taxonomy_csv.term.api.inc, line 40
Find, get and set full or detail term items.

Code

function taxonomy_csv_term_load_multiple($tids = array(), $conditions = array()) {
  $terms = array();

  // Flag use to determine if select query has already conditions.
  $flag = FALSE;

  // Prepare query for terms to be loaded.
  $sql = "\n    SELECT t.*\n    FROM {term_data} t\n  ";
  $args = array();
  if ($tids) {
    $sql .= ' WHERE (t.tid = %d' . str_repeat(' OR t.tid = %d', count($tids) - 1) . ')';
    $args += array_values($tids);
    $flag = TRUE;
  }
  if (isset($conditions['vid']) && $conditions['vid']) {
    $sql .= $flag ? ' AND ' : ' WHERE ';
    $sql .= '(t.vid = %d)';
    $args[] = $conditions['vid'];
    $flag = TRUE;
  }
  if (isset($conditions['order']) && $conditions['order']) {
    $sql .= ' ORDER BY %s ASC';
    $args[] = $conditions['order'];
  }
  $result = db_query($sql, $args);
  while ($term = db_fetch_object($result)) {
    $terms[] = taxonomy_csv_term_get_full($term);
  }
  return $terms;
}