Interface for building SQL queries in a database-agnostic way.
Provides methods for constructing, manipulating, and rendering SQL statements for CRUD operations, joins, grouping, ordering, and schema management. Implementations must support chaining and flexible query composition.
public setReservedWords(array $words): void
| Parameter | Type | Description |
|---|
$words | array | |
Generates a CREATE statement for a table or object.
public create(string $name, string $type, bool $ifNotExists): string
| Parameter | Type | Description |
|---|
$name | string | |
$type | string | |
$ifNotExists | bool | |
Generates an INSERT statement for the specified fields.
public insert(mixed $fields): self
| Parameter | Type | Description |
|---|
$fields | mixed | |
public update(array $fields): self
| Parameter | Type | Description |
|---|
$fields | array | |
Generates a DELETE statement for the current query context.
Generates a TRUNCATE statement for the current table.
public truncate(bool $cascade): self
| Parameter | Type | Description |
|---|
$cascade | bool | |
Generates a COUNT statement for the current query context.
Generates an EXISTS statement for the specified table and criteria.
public exists(string $table, mixed $criteria): string
| Parameter | Type | Description |
|---|
$table | string | |
$criteria | mixed | |
Specifies columns to select in the query.
public select(mixed $columns): self
| Parameter | Type | Description |
|---|
$columns | mixed | |
Specifies DISTINCT columns for the query.
public distinct(string $columns): self
| Parameter | Type | Description |
|---|
$columns | string | |
Sets the table for the query, optionally with an alias.
public table(string $table, ?string $alias): self
| Parameter | Type | Description |
|---|
$table | string | |
$alias | string | |
Sets the FROM clause for the query, optionally with an alias.
public from(string $table, ?string $alias): self
| Parameter | Type | Description |
|---|
$table | string | |
$alias | string | |
public where(string $criteria): self
| Parameter | Type | Description |
|---|
$criteria | string | |
Adds GROUP BY clause to the query.
public group(string $column): self
| Parameter | Type | Description |
|---|
$column | string | |
public having(array $criteria): self
| Parameter | Type | Description |
|---|
$criteria | array | |
public window(string $name, string $partitionBy, null $orderBy): self
| Parameter | Type | Description |
|---|
$name | string | |
$partitionBy | string | |
$orderBy | null | |
Join a table to the current query using the provided join criteria.
public join(string $references, null $on, ?string $alias, string $type = 'INNER'): self
| Parameter | Type | Description |
|---|
$references | string | |
$on | null | |
$alias | string | |
$type | string | |
Adds a UNION clause with another query.
public union(QueryBuilder $query): self
| Parameter | Type | Description |
|---|
$query | QueryBuilder | |
Adds a UNION ALL clause with another query.
public unionAll(QueryBuilder $query): self
| Parameter | Type | Description |
|---|
$query | QueryBuilder | |
Adds an INTERSECT clause with another query.
public intersect(QueryBuilder $query): self
| Parameter | Type | Description |
|---|
$query | QueryBuilder | |
Adds an EXCEPT clause with another query.
public except(QueryBuilder $query): self
| Parameter | Type | Description |
|---|
$query | QueryBuilder | |
public order(string $columns, int $sortDirection = 'SORT_ASC'): self
| Parameter | Type | Description |
|---|
$columns | string | |
$sortDirection | int | |
Sets the LIMIT clause for the query.
public limit(int $limit): self
| Parameter | Type | Description |
|---|
$limit | int | |
Sets the OFFSET clause for the query.
public offset(int $offset): self
| Parameter | Type | Description |
|---|
$offset | int | |
Returns the SQL string representation of the query.
public toString(): string
Returns the schema name for the current query context.
public getSchemaName(): ?string
public parseSchemaName(string $tableName): void
| Parameter | Type | Description |
|---|
$tableName | string | |
Returns the fully qualified schema name for a table.
public schemaName(string $tableName): string
| Parameter | Type | Description |
|---|
$tableName | string | |
Quotes a value for use in SQL, handling special cases.
public quoteSpecial(mixed $value): mixed
| Parameter | Type | Description |
|---|
$value | mixed | |
Quotes or formats a field name for SQL usage.
public field(string $string): string
| Parameter | Type | Description |
|---|
$string | string | |
public prepareFields(mixed $fields, array $exclude, array $tables): string
| Parameter | Type | Description |
|---|
$fields | mixed | |
$exclude | array | |
$tables | array | |
Prepares a value for SQL binding, handling type and quoting.
public prepareValue(string $key, mixed $value): mixed
| Parameter | Type | Description |
|---|
$key | string | |
$value | mixed | |
public prepareArrayAliases(array $array): void
| Parameter | Type | Description |
|---|
$array | array | |
public prepareCriteria(string $criteria, string $bindType = 'AND', string $tissue = '=', ?string $parentRef, bool $setKey = true): string
| Parameter | Type | Description |
|---|
$criteria | string | |
$bindType | string | |
$tissue | string | |
$parentRef | string | |
$setKey | bool | |
Resets the internal state of the query builder, clearing all clauses and parameters.
public getCriteriaValues(): void
public prepareCriteriaValues(array $paramValues): void
| Parameter | Type | Description |
|---|
$paramValues | array | |
Specifies columns to return from an INSERT, UPDATE, or DELETE statement (RETURNING clause).
public returning(mixed $columns): self
| Parameter | Type | Description |
|---|
$columns | mixed | |
public onConflict(null $target, null $update): self
| Parameter | Type | Description |
|---|
$target | null | |
$update | null | |
Generated by Hazaar API Doc Generator on Tue, 21 Apr 2026 04:00:25 +0000