SqlBuilder
class SqlBuilder
Builds SQL queries for the Explorer layer.
Properties
| protected | $tableName | ||
| protected | $conventions | ||
| protected | $delimitedTable | ||
| protected string[] | $select | ||
| protected string[] | $where | ||
| protected array<string,string[]> | $joinCondition | ||
| protected array<string,string|string[]> | $conditions | ||
| protected array<string,array> | $parameters | ||
| protected string[] | $order | ||
| protected | $limit | ||
| protected | $offset | ||
| protected | $group | ||
| protected | $having | ||
| protected array<string,string> | $reservedTableNames | ||
| protected array<string,string> | $aliases | ||
| protected | $currentAlias |
Methods
No description
No description
No description
No description
Returns select query hash for caching.
Returns SQL query.
No description
Copies GROUP BY and HAVING clauses from another builder. Returns true if HAVING was present.
Adds SELECT clause, more calls append to the end.
No description
No description
Adds WHERE condition, more calls append with AND.
Adds JOIN condition.
Normalizes and appends a condition with its parameters. Deduplicates identical conditions.
No description
Adds alias AS.
Ensures a table alias is not used for two different chains, throwing on conflict.
Adds ORDER BY clause, more calls append to the end.
No description
No description
Sets LIMIT/OFFSET clause.
No description
No description
Sets GROUP BY and HAVING clause.
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
Delimits lowercase identifiers in a SQL fragment while leaving uppercase keywords untouched.
Adds a multi-column IN condition using OR expansion or tuple syntax depending on driver support.
Details
at line 73
__construct(string $tableName, Explorer $explorer)
No description
at line 85
string
getTableName()
No description
at line 91
string
buildInsertQuery()
No description
at line 97
string
buildUpdateQuery()
No description
at line 113
string
buildDeleteQuery()
No description
at line 128
string
getSelectQueryHash(array|null $columns = null)
Returns select query hash for caching.
at line 162
string
buildSelectQuery(array|null $columns = null)
Returns SQL query.
at line 212
array
getParameters()
No description
at line 232
void
importConditions(SqlBuilder $builder)
Copies WHERE conditions and aliases from another builder.
at line 247
bool
importGroupConditions(SqlBuilder $builder)
Copies GROUP BY and HAVING clauses from another builder. Returns true if HAVING was present.
at line 267
void
addSelect(string $columns, mixed ...$params)
Adds SELECT clause, more calls append to the end.
at line 275
array
getSelect()
No description
at line 281
void
resetSelect()
No description
at line 292
bool
addWhere(string|array $condition, mixed ...$params)
Adds WHERE condition, more calls append with AND.
at line 302
bool
addJoinCondition(string $tableChain, string|array $condition, mixed ...$params)
Adds JOIN condition.
at line 321
protected bool
addCondition(string|array $condition, array $params, array $conditions, array $conditionsParameters)
Normalizes and appends a condition with its parameters. Deduplicates identical conditions.
Returns true if the condition was added, false if it was a duplicate.
at line 468
array
getConditions()
No description
at line 477
void
addAlias(string $chain, string $alias)
Adds alias AS.
at line 491
protected void
checkUniqueTableName(string $tableName, string $chain)
Ensures a table alias is not used for two different chains, throwing on conflict.
at line 512
void
addOrder(string $columns, mixed ...$params)
Adds ORDER BY clause, more calls append to the end.
at line 523
void
setOrder(array $columns, array $parameters)
No description
at line 531
array
getOrder()
No description
at line 540
void
setLimit(int|null $limit, int|null $offset)
Sets LIMIT/OFFSET clause.
at line 547
int|null
getLimit()
No description
at line 553
int|null
getOffset()
No description
at line 562
void
setGroup(string $columns, mixed ...$params)
Sets GROUP BY and HAVING clause.
at line 569
string
getGroup()
No description
at line 575
void
setHaving(string $having, mixed ...$params)
No description
at line 582
string
getHaving()
No description
at line 592
protected string
buildSelect(array $columns)
No description
at line 603
protected array
parseJoinConditions(array $joins, array $joinConditions)
No description
at line 644
protected void
getSortedJoins(string $table, array $leftJoinDependency, array $tableJoins, array $finalJoins)
No description
at line 698
protected void
parseJoins(array $joins, string $query)
No description
at line 718
string
parseJoinsCb(array $joins, array $match)
No description
at line 841
protected string
buildQueryJoins(array $joins, array $leftJoinConditions = [])
No description
at line 858
protected array
buildJoinConditions()
No description
at line 869
protected string
buildConditions()
No description
at line 877
protected string
buildQueryEnd()
No description
at line 899
protected string
tryDelimite(string $s)
Delimits lowercase identifiers in a SQL fragment while leaving uppercase keywords untouched.
at line 918
protected bool
addConditionComposition(array $columns, array $parameters, array $conditions, array $conditionsParameters)
Adds a multi-column IN condition using OR expansion or tuple syntax depending on driver support.