You are here

public static function PhotosAlbum::getCount in Album Photos 6.0.x

Same name and namespace in other branches
  1. 8.5 src/PhotosAlbum.php \Drupal\photos\PhotosAlbum::getCount()
  2. 8.4 src/PhotosAlbum.php \Drupal\photos\PhotosAlbum::getCount()

Return number of albums or photos.

2 calls to PhotosAlbum::getCount()
PhotosAlbum::userAlbumCount in src/PhotosAlbum.php
Tracks number of albums created and number of albums allowed.
photos_user_load in ./photos.module
Implements hook_ENTITY_TYPE_load().

File

src/PhotosAlbum.php, line 528

Class

PhotosAlbum
Create an album object.

Namespace

Drupal\photos

Code

public static function getCount($type, $id = 0) {
  $db = \Drupal::database();
  switch ($type) {
    case 'user_album':
    case 'user_image':
    case 'site_album':
    case 'site_image':
      return $db
        ->query("SELECT value FROM {photos_count} WHERE cid = :cid AND type = :type", [
        ':cid' => $id,
        ':type' => $type,
      ])
        ->fetchField();
    case 'node_album':
      return $db
        ->query("SELECT count FROM {photos_album} WHERE album_id = :album_id", [
        ':album_id' => $id,
      ])
        ->fetchField();
  }
}