You are here

function taxonomy_csv_term_count_in_vocabulary in Taxonomy CSV import/export 7.4

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

Calculate number of terms in a vocabulary or in all vocabularies.

@todo Regular query.

Parameters

$vocabulary_id: (Optional) Id of the chosen vocabulary. If not specified, count terms in all vocabularies.

Return value

Number of terms in specified vocabulary or in all vocabularies.

2 calls to taxonomy_csv_term_count_in_vocabulary()
taxonomy_csv_vocabulary_export in export/taxonomy_csv.export.api.inc
Prepare the export of a vocabulary. If not used in a form, don't forget to use batch_process().
_taxonomy_csv_export_check_options in export/taxonomy_csv.export.admin.inc
Validate options of exported vocabulary.

File

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

Code

function taxonomy_csv_term_count_in_vocabulary($vocabulary_id = 0) {

  // @todo Use taxonomy api or regular Drupal 7 query.
  $sql = "\n    SELECT COUNT(*) AS count\n    FROM {taxonomy_term_data}\n  ";
  $args = array();
  if ($vocabulary_id) {
    $sql .= ' WHERE vid = :vid ';
    $args[':vid'] = $vocabulary_id;
  }
  $result = db_query($sql, $args);
  foreach ($result as $item) {
    return $item->count;
  }
}