You are here

function taxonomy_csv_vocabulary_count_terms in Taxonomy CSV import/export 7.5

Same name and namespace in other branches
  1. 6.5 taxonomy_csv.vocabulary.api.inc \taxonomy_csv_vocabulary_count_terms()

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

Parameters

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

Return value

Number of terms in specified vocabularies or in all vocabularies.

2 calls to taxonomy_csv_vocabulary_count_terms()
taxonomy_csv_vocabulary_export in export/taxonomy_csv.export.api.inc
Prepare the export of a vocabulary.
_taxonomy_csv_export_check_options in export/taxonomy_csv.export.admin.inc
Validate options of exported vocabulary.

File

./taxonomy_csv.vocabulary.api.inc, line 144
Prepare and manage vocabularies.

Code

function taxonomy_csv_vocabulary_count_terms($vocabulary_id = 0) {
  if (!is_array($vocabulary_id)) {
    $vocabulary_id = array(
      $vocabulary_id,
    );
  }
  $sql = "\n    SELECT COUNT(*)\n    FROM {taxonomy_term_data}\n  ";
  $args = array();
  if ($vocabulary_id != array(
    0,
  ) && $vocabulary_id != array(
    '0',
  )) {
    $sql .= ' WHERE vid IN (:vid) ';
    $args[':vid'] = $vocabulary_id;
  }
  $result = db_query($sql, $args)
    ->fetchField();
  return $result;
}