You are here

function hosting_site_count in Hosting 7.4

Same name and namespace in other branches
  1. 5 site/hosting_site.module \hosting_site_count()
  2. 6.2 site/hosting_site.module \hosting_site_count()
  3. 7.3 site/hosting_site.module \hosting_site_count()

Returns a count of sites.

This is used by cron and statistics to batch the number of sites that are processed with each call. It is also used to generate the 'site count' per platform at /hosting/platforms

By default it only counts enabled sites.

Optionally can include an array of site statuses by which to consider in the count.

Parameters

$platform: (optional) A platform nid to only count sites on that specific platform.

$statuses: (optional) An array of site statuses (defined by their constants) by which to include such sites in the site count.

Return value

The number of sites matching the specified criteria.

2 calls to hosting_site_count()
hosting_cron_hosting_queues in cron/hosting_cron.module
Implements hook_hosting_queues().
hosting_platform_handler_field_sites::render in platform/includes/views/handlers/hosting_platform_handler_field_sites.inc
Render the field.

File

site/hosting_site.module, line 513
Contains hook implementations for Hosting site module.

Code

function hosting_site_count($platform = NULL, $statuses = NULL) {
  if (is_null($statuses)) {
    $statuses = array(
      HOSTING_SITE_ENABLED,
    );
  }
  $query = db_select('hosting_site')
    ->addTag('hosting_site_count')
    ->fields('hosting_site', array(
    'nid',
  ));
  if (count($statuses)) {
    $query
      ->condition('status', $statuses);
  }
  if (!is_null($platform)) {
    $query
      ->condition('platform', $platform);
  }
  return $query
    ->countQuery()
    ->execute()
    ->fetchField();
}