Database API
by Gisle Hannemyr
Mumble
Table of contents
Sources: DO: Static Queries, Berdir: timeout 2022-05-29.
Introduction
For Symfoni-based Drupal, all db_*
procedural functions of the Database API layer have been deprecated.
See DO: db_* procedural functions of the Database API layer have been deprecated.
Using EntityFieldQuery
sitepoint.com: The Drupal 8 version of EntityFieldQuery.
Counting items
Assuming that field_year
exists, this will count
the number of published nodes with that field set
to 2017
.
$query = new EntityFieldQuery(); $query->entityCondition('entity_type', 'node') ->entityCondition('bundle', 'article') ->propertyCondition('status', NODE_PUBLISHED) ->fieldCondition('field_year', 'value', '2017', '='); $count = $query->count()->execute();
Final word
[TBA]
Last update: 2019-11-29 [gh].