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 74
__construct(string $tableName, Explorer $explorer)
No description
at line 86
string
getTableName()
No description
at line 92
string
buildInsertQuery()
No description
at line 98
string
buildUpdateQuery()
No description
at line 114
string
buildDeleteQuery()
No description
at line 129
string
getSelectQueryHash(array|null $columns = null)
Returns select query hash for caching.
at line 163
string
buildSelectQuery(array|null $columns = null)
Returns SQL query.
at line 213
array
getParameters()
No description
at line 233
void
importConditions(SqlBuilder $builder)
Copies WHERE conditions and aliases from another builder.
at line 248
bool
importGroupConditions(SqlBuilder $builder)
Copies GROUP BY and HAVING clauses from another builder. Returns true if HAVING was present.
at line 268
void
addSelect(string $columns, mixed ...$params)
Adds SELECT clause, more calls append to the end.
at line 276
array
getSelect()
No description
at line 282
void
resetSelect()
No description
at line 293
bool
addWhere(string|array $condition, mixed ...$params)
Adds WHERE condition, more calls append with AND.
at line 303
bool
addJoinCondition(string $tableChain, string|array $condition, mixed ...$params)
Adds JOIN condition.
at line 322
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 469
array
getConditions()
No description
at line 478
void
addAlias(string $chain, string $alias)
Adds alias AS.
at line 492
protected void
checkUniqueTableName(string $tableName, string $chain)
Ensures a table alias is not used for two different chains, throwing on conflict.
at line 513
void
addOrder(string $columns, mixed ...$params)
Adds ORDER BY clause, more calls append to the end.
at line 524
void
setOrder(array $columns, array $parameters)
No description
at line 532
array
getOrder()
No description
at line 541
void
setLimit(int|null $limit, int|null $offset)
Sets LIMIT/OFFSET clause.
at line 548
int|null
getLimit()
No description
at line 554
int|null
getOffset()
No description
at line 563
void
setGroup(string $columns, mixed ...$params)
Sets GROUP BY and HAVING clause.
at line 570
string
getGroup()
No description
at line 576
void
setHaving(string $having, mixed ...$params)
No description
at line 583
string
getHaving()
No description
at line 593
protected string
buildSelect(array $columns)
No description
at line 604
protected array
parseJoinConditions(array $joins, array $joinConditions)
No description
at line 645
protected void
getSortedJoins(string $table, array $leftJoinDependency, array $tableJoins, array $finalJoins)
No description
at line 699
protected void
parseJoins(array $joins, string $query)
No description
at line 719
string
parseJoinsCb(array $joins, array $match)
No description
at line 842
protected string
buildQueryJoins(array $joins, array $leftJoinConditions = [])
No description
at line 859
protected array
buildJoinConditions()
No description
at line 870
protected string
buildConditions()
No description
at line 878
protected string
buildQueryEnd()
No description
at line 900
protected string
tryDelimit(string $s)
Delimits lowercase identifiers in a SQL fragment while leaving uppercase keywords untouched.
at line 919
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.