Extra Block Types (EBT) - New Layout Builder experience❗
Extra Block Types (EBT) - styled, customizable block types: Slideshows, Tabs, Cards, Accordions and many others. Built-in settings for background, DOM Box, javascript plugins. Experience the future of layout building today.
❗Extra Paragraph Types (EPT) - New Paragraphs experience
Extra Paragraph Types (EPT) - analogical paragraph based set of modules.
Query count()
Menu
- Understanding Drupal
- Drupal System Requirements
- Installing Drupal 8
- Drupal 8 Update
- Drupal Site Administration
- Drupal 8 Modules
- Drupal Modules Comparison
- Drupal Themes
- Drupal field types
- Configuration Management
- Multisite Drupal
- Accessibility Features
- Troubleshooting in Drupal
- Creating modules for Drupal
-
Drupal 8 API
- Authentication API
- Block API
- Cache API
- CKEditor API
- Configuration Management API
- Database API
- Entity API
- Theming in Drupal
- Upgrade to Drupal 11
Any query can have a corresponding "count query". A count query returns the number of rows in the original query. To get a count query from an existing query (which is a select query object implementing the SelectInterface), use the countQuery()
method.
$count_query = $query->countQuery();
$count_query
is now a new dynamic select query without order constraints, which when executed will return a result set with only one value — the number of records that would match the original query. Since PHP supports method chaining on returned objects, the following approach is common:
$num_rows = $query->countQuery()->execute()->fetchField();
For an entity query (implementing the QueryInterface), the code is slightly different:
$num_rows = $query->count()->execute();