You are here

function taxonomy_csv_vocabulary_count_terms in Taxonomy CSV import/export 6.5

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

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

@todo Regular query.

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. 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.vocabulary.api.inc, line 203
Prepare and manage vocabularies.

Code

function taxonomy_csv_vocabulary_count_terms($vocabulary_id = 0) {
  $sql = "\n    SELECT COUNT(*)\n    FROM {term_data}\n  ";
  $args = array();
  if ($vocabulary_id) {
    if (is_array($vocabulary_id)) {
      if ($vocabulary_id != array(
        0,
      ) && $vocabulary_id != array(
        '0',
      )) {
        $sql .= ' WHERE vid IN (' . implode(',', $vocabulary_id) . ') ';
      }
    }
    else {
      $sql .= ' WHERE vid = %d ';
      $args[] = $vocabulary_id;
    }
  }
  return array_shift(db_fetch_array(db_query($sql, $args)));
}