Declarative Query Configuration
The QueryConfig class provides a configuration-based alternative to the fluent builder API. It is covered in detail in the Query Builder page, under the Declarative Query Configuration section.
Quick Reference
use Derafu\Query\Config\QueryConfig;
// From an array.
$config = new QueryConfig([
'table' => 'products',
'select' => 'id, name, price',
'where' => 'category?=electronics',
'orderBy' => ['price' => 'DESC'],
'limit' => 10,
]);
$result = $config->applyTo($queryBuilder)->execute();
// From a YAML file.
$config = QueryConfig::fromYamlFile('queries/product_report.yaml');
// From a JSON file.
$config = QueryConfig::fromJsonFile('queries/sales.json');
// Auto-detect format by extension.
$config = QueryConfig::fromFile('queries/report.yaml');
Supported Configuration Keys
| Key | Description |
|---|---|
table |
Table name (FROM clause) |
alias |
Table alias |
select |
Columns to select |
distinct |
true to add DISTINCT |
where |
WHERE condition(s) |
andWhere |
Additional AND condition(s) |
orWhere |
OR condition(s) |
andWhereOr |
AND with nested OR groups |
innerJoin |
{table, condition, alias?} |
leftJoin |
{table, condition, alias?} |
rightJoin |
{table, condition, alias?} |
crossJoin |
{table, alias?} |
groupBy |
GROUP BY column(s) |
having |
HAVING condition(s) |
orderBy |
{column: direction} pairs |
limit |
Max rows to return |
offset |
Rows to skip |
For full documentation, examples, and API-driven query patterns, see Query Builder → Declarative Query Configuration.
On this page
Last updated on 05/05/2026
by Anonymous