-
Notifications
You must be signed in to change notification settings - Fork 2
QueryGrammar
Viames Marino edited this page Feb 23, 2026
·
1 revision
Pair\Orm\QueryGrammar compiles a Query object into raw SQL.
It handles clause compilation and identifier wrapping.
- compile select/from/join/where/group/having/order/limit/offset
- compile nested/exists/in/between/null where clauses
- compile join clause variations from
JoinClause - safely wrap identifiers and aliased identifiers
Produces final SQL for a select query.
Query::toSql() delegates to this compiler.
compileColumns()compileFrom()compileJoins()compileWheres()compileGroups()compileHavings()compileOrders()compileLimit()compileOffset()
You usually do not call QueryGrammar directly, but understanding it helps when:
- diagnosing generated SQL
- mixing raw clauses with fluent builder
- working on query builder internals
use Pair\Orm\Query;
$query = Query::table('users')
->where('active', 1)
->orderBy('created_at', 'desc')
->limit(10);
$sql = $query->toSql();
$bindings = $query->getBindings();See also: Query, JoinClause, Database.