TaxSql final class
Minn\Query\TaxSql · public/minn/src/Minn/Query/TaxSql.php · 197 lines
The JOIN and WHERE fragments of a taxonomy query in the reference's shape: IN clauses join term_relationships (the first under the table's own name, then tt1, tt2, ..., shared between IN siblings under OR), NOT IN and AND read subqueries, EXISTS checks the taxonomy, and a term nobody has yields "0 = 1".
Constants and properties
| private | int $aliasCount | |
| private | readonly string $relationships | Promoted from the constructor. |
| private | readonly string $termTaxonomy | Promoted from the constructor. |
| private | readonly string $primaryTable | Promoted from the constructor. |
| private | readonly string $primaryId | Promoted from the constructor. |
| private | readonly Closure $termTaxonomyIds | Promoted from the constructor. |
Public
| new | __construct(string $relationships, string $termTaxonomy, string $primaryTable, string $primaryId, Closure $termTaxonomyIds)# |
| |||
| static | sanitize(array $queries): array# | The query as the reference keeps it: each clause merged over the defaults (taxonomy, terms as a list, field term_id, operator IN, children included), a nested group given relation AND when it has none, an empty group dropped. The top level keeps a relation only when one was given.
@return array<array-key, mixed> | |||
| static | isFirstOrder(mixed $query): bool# | Whether a query part is a clause (it names a clause key, or is empty) rather than a group. | |||
| static | queried(array $queries, array $queried = array ( )): array# | The terms a sanitized query asks for, by taxonomy: the first terms and the first field each taxonomy's clauses give, NOT IN clauses aside.
@return array<string, array{terms?: list<mixed>, field?: string}> | |||
| method | build(array $queries): array# | The JOIN and WHERE fragments for a taxonomy query. @return array{join: string, where: string} | |||
| method | sqlClauses(array $queries): array# | The whole query's JOIN and WHERE (get_sql_clauses), each clause settled in place. @return array{join: string, where: string} @return array{join: string, where: string} | |||
| method | querySql(array $queries, int $depth): array# | A group's JOIN and WHERE (get_sql_for_query), indented for its depth. @return array{join: string, where: string} @return array{join: string, where: string} | |||
| method | clauseSql(array $clause, array $parent): array# | One clause's JOIN and WHERE pieces (get_sql_for_clause). Its terms are turned into term_taxonomy_ids in place; an IN clause reads term_relationships under an alias it shares with a compatible sibling or joins anew, and keeps that alias. A term nobody has yields "0 = 1" (nothing at all for NOT IN). @return array{where: list<string>, join: list<string>} | |||
| method | compatibleAlias(array $clause, array $parent): string|false# | The alias of an IN sibling the clause can share under OR (find_compatible_table_alias), or false. |
Internals 2
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
Nothing matches.