BuildTextFilters
in package
Use case for building text query filters.
Constructs WHERE and HAVING clauses for text list queries based on search criteria and tag filters.
Tags
Table of Contents
Methods
- buildArchivedQueryWhereClause() : array{clause: string, params: array}
- Build WHERE clause for archived text query filtering.
- buildArchivedTagHavingClause() : string
- Build HAVING clause for archived text tag filtering.
- buildQueryWhereClause() : array{clause: string, params: array}
- Build WHERE clause for text query filtering.
- buildTagHavingClause() : string
- Build HAVING clause for tag filtering.
- buildTextTagHavingClause() : string
- Build HAVING clause for active text tag filtering.
- validateRegexQuery() : bool
- Validate regex query (test if regex is valid).
Methods
buildArchivedQueryWhereClause()
Build WHERE clause for archived text query filtering.
public
buildArchivedQueryWhereClause(string $query, string $queryMode, string $regexMode) : array{clause: string, params: array}
Note: Archived texts are now stored in the texts table with TxArchivedAt set, so they use the same Tx column prefix as active texts.
Parameters
- $query : string
-
Search query string
- $queryMode : string
-
Query mode
- $regexMode : string
-
Regex mode
Return values
array{clause: string, params: array}buildArchivedTagHavingClause()
Build HAVING clause for archived text tag filtering.
public
buildArchivedTagHavingClause(string|int $tag1, string|int $tag2, string $tag12) : string
Note: Archived texts now use the same text_tag_map table as active texts, so they use the same TtT2ID column.
Parameters
- $tag1 : string|int
-
First tag filter
- $tag2 : string|int
-
Second tag filter
- $tag12 : string
-
AND/OR operator
Return values
string —SQL HAVING clause
buildQueryWhereClause()
Build WHERE clause for text query filtering.
public
buildQueryWhereClause(string $query, string $queryMode, string $regexMode[, string $tablePrefix = 'Tx' ]) : array{clause: string, params: array}
Parameters
- $query : string
-
Search query string
- $queryMode : string
-
Query mode ('title,text', 'title', 'text')
- $regexMode : string
-
Regex mode ('' for LIKE, 'r' for RLIKE)
- $tablePrefix : string = 'Tx'
-
Column prefix ('Tx' for texts, 'At' for archived)
Return values
array{clause: string, params: array} —SQL WHERE clause and parameters
buildTagHavingClause()
Build HAVING clause for tag filtering.
public
buildTagHavingClause(string|int $tag1, string|int $tag2, string $tag12[, string $tagIdCol = 'TtT2ID' ]) : string
Parameters
- $tag1 : string|int
-
First tag filter (must be numeric or empty)
- $tag2 : string|int
-
Second tag filter (must be numeric or empty)
- $tag12 : string
-
AND/OR operator
- $tagIdCol : string = 'TtT2ID'
-
Tag ID column (AgT2ID for archived, TtT2ID for active)
Return values
string —SQL HAVING clause
buildTextTagHavingClause()
Build HAVING clause for active text tag filtering.
public
buildTextTagHavingClause(string|int $tag1, string|int $tag2, string $tag12) : string
Parameters
- $tag1 : string|int
-
First tag filter
- $tag2 : string|int
-
Second tag filter
- $tag12 : string
-
AND/OR operator
Return values
string —SQL HAVING clause
validateRegexQuery()
Validate regex query (test if regex is valid).
public
validateRegexQuery(string $query, string $regexMode) : bool
Parameters
- $query : string
-
Query string
- $regexMode : string
-
Regex mode
Return values
bool —True if valid, false if invalid