Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. DatabaseQueue.php

function DatabaseQueue::numberOfItems

Overrides QueueInterface::numberOfItems

File

core/lib/Drupal/Core/Queue/DatabaseQueue.php, line 102

Class

DatabaseQueue
Default queue implementation.

Namespace

Drupal\Core\Queue

Code

public function numberOfItems() {
    try {
        return (int) $this->connection
            ->query('SELECT COUNT([item_id]) FROM {' . static::TABLE_NAME . '} WHERE [name] = :name', [
            ':name' => $this->name,
        ])
            ->fetchField();
    } catch (\Exception $e) {
        $this->catchException($e);
        // If there is no table there cannot be any items.
        return 0;
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal