Documentation

MySqlTextTagRepository implements TagRepositoryInterface

MySQL implementation of TagRepositoryInterface for text tags.

Operates on the 'text_tags' table for text/document tags.

Tags
since
3.0.0

Table of Contents

Interfaces

TagRepositoryInterface
Repository interface for Tag entity.

Constants

COL_PREFIX  = 'T2'
TABLE_NAME  = 'text_tags'

Methods

count()  : int
Get total count of tags matching a filter.
delete()  : bool
Delete a tag by ID.
deleteAll()  : int
Delete all tags matching a filter.
deleteMultiple()  : int
Delete multiple tags by IDs.
exists()  : bool
Check if a tag exists by ID.
find()  : Tag|null
Find a tag by its ID.
findAll()  : array<string|int, Tag>
Find all tags ordered by specified column.
findByText()  : Tag|null
Find a tag by its text.
getAllTexts()  : array<string|int, string>
Get all tag texts as an array.
getArchivedUsageCount()  : int
Get the number of archived texts using this tag.
getOrCreate()  : int
Get or create a tag by text.
getTagType()  : TagType
Get the tag type this repository handles.
getUsageCount()  : int
Get usage count for a specific tag.
paginate()  : Tag[], usageCounts: array, totalCount: int}
Get paginated list of tags with usage counts.
save()  : void
Save a tag entity (create or update).
textExists()  : bool
Check if a tag text exists.
buildWhereClause()  : array{clause: string, params: list}
Build WHERE clause for query filtering.
mapOrderByColumn()  : string
Map order by parameter to column name.
mapToEntity()  : Tag
Map a database row to a Tag entity.
query()  : QueryBuilder
Get a query builder for this repository's table.

Constants

Methods

count()

Get total count of tags matching a filter.

public count([string $query = '' ]) : int
Parameters
$query : string = ''

Filter query (supports * wildcard)

Return values
int

delete()

Delete a tag by ID.

public delete(int $id) : bool
Parameters
$id : int

Tag ID

Return values
bool

True if deleted, false if not found

deleteAll()

Delete all tags matching a filter.

public deleteAll([string $query = '' ]) : int
Parameters
$query : string = ''

Filter query (supports * wildcard)

Return values
int

Number of deleted tags

deleteMultiple()

Delete multiple tags by IDs.

public deleteMultiple(array<string|int, mixed> $ids) : int
Parameters
$ids : array<string|int, mixed>

Tag IDs to delete

Return values
int

Number of deleted tags

exists()

Check if a tag exists by ID.

public exists(int $id) : bool
Parameters
$id : int

Tag ID

Return values
bool

find()

Find a tag by its ID.

public find(int $id) : Tag|null
Parameters
$id : int

Tag ID

Return values
Tag|null

Tag entity or null if not found

findAll()

Find all tags ordered by specified column.

public findAll([string $orderBy = 'text' ][, string $direction = 'ASC' ]) : array<string|int, Tag>
Parameters
$orderBy : string = 'text'

Column to order by ('text', 'comment', 'usage')

$direction : string = 'ASC'

Sort direction ('ASC' or 'DESC')

Return values
array<string|int, Tag>

findByText()

Find a tag by its text.

public findByText(string $text) : Tag|null
Parameters
$text : string

Tag text (case-sensitive)

Return values
Tag|null

Tag entity or null if not found

getAllTexts()

Get all tag texts as an array.

public getAllTexts() : array<string|int, string>
Return values
array<string|int, string>

getArchivedUsageCount()

Get the number of archived texts using this tag.

public getArchivedUsageCount(int $tagId) : int
Parameters
$tagId : int

Tag ID

Return values
int

Archived usage count

getOrCreate()

Get or create a tag by text.

public getOrCreate(string $text) : int
Parameters
$text : string

Tag text

Return values
int

Tag ID

getUsageCount()

Get usage count for a specific tag.

public getUsageCount(int $tagId) : int
Parameters
$tagId : int

Tag ID

Return values
int

paginate()

Get paginated list of tags with usage counts.

public paginate(int $page, int $perPage[, string $query = '' ][, string $orderBy = 'text' ]) : Tag[], usageCounts: array, totalCount: int}
Parameters
$page : int

Page number (1-based)

$perPage : int

Items per page

$query : string = ''

Filter query (supports * wildcard)

$orderBy : string = 'text'

Column to order by

Return values
Tag[], usageCounts: array, totalCount: int}

textExists()

Check if a tag text exists.

public textExists(string $text[, int|null $excludeId = null ]) : bool
Parameters
$text : string

Tag text to check

$excludeId : int|null = null

Tag ID to exclude (for updates)

Return values
bool

buildWhereClause()

Build WHERE clause for query filtering.

private buildWhereClause(string $query) : array{clause: string, params: list}
Parameters
$query : string

Filter query string

Return values
array{clause: string, params: list}

mapOrderByColumn()

Map order by parameter to column name.

private mapOrderByColumn(string $orderBy) : string
Parameters
$orderBy : string

Order by parameter

Return values
string

Column name with direction

mapToEntity()

Map a database row to a Tag entity.

private mapToEntity(array<string, mixed> $row) : Tag
Parameters
$row : array<string, mixed>

Database row

Return values
Tag

        
On this page

Search results