Dynamic queries

Drupal 7 will no longer be supported after January 5, 2025. Learn more and find resources for Drupal 7 sites

Dynamic queries in Drupal 7 Database API.

Introduction to dynamic queries

Dynamic queries refer to queries that are built dynamically by Drupal rather than provided as an explicit query string.

Conditional clauses

A "conditional clause" is a portion of a query that restricts the rows matched by certain conditions.

Count queries

Count queries return the number of rows in a query.

Distinct

Distinct

Expressions

Expressions

Extenders

Extenders add functionality to Select query objects at runtime.

Fields

Add a field

Grouping

Grouping

Joins

Joins

Ordering

Ordering

Query alteration (tagging)

An important feature of dynamic select queries is the ability of other modules to alter them on the fly. That allows other modules to

Ranges and limits

Ranges and Limits

Table sorting

Table sorting

Unions

Unions

Guide maintainers

drupalastic's picture