MySqlWordTagAssociation
in package
implements
TagAssociationInterface
MySQL implementation of TagAssociationInterface for word-tag links.
Operates on the 'word_tag_map' junction table.
Tags
Table of Contents
Interfaces
- TagAssociationInterface
- Interface for managing tag associations with entities.
Constants
- ITEM_COLUMN = 'WtWoID'
- TABLE_NAME = 'word_tag_map'
- TAG_COLUMN = 'WtTgID'
Properties
Methods
- __construct() : mixed
- Constructor.
- addTag() : bool
- Add a tag to an item.
- addTagToItems() : int
- Add a tag to multiple items.
- cleanupOrphanedLinks() : int
- Clean up orphaned tag links.
- clearItemsForTag() : int
- Remove all associations for a tag.
- clearTagsForItem() : int
- Remove all associations for an item.
- getItemCount() : int
- Get count of items associated with a tag.
- getTagIdsForItem() : array<string|int, int>
- Get all tag IDs associated with an item.
- getTagTextsForItem() : array<string|int, string>
- Get all tag texts associated with an item.
- hasTag() : bool
- Check if a tag is associated with an item.
- removeTag() : bool
- Remove a tag from an item.
- removeTagFromItems() : int
- Remove a tag from multiple items.
- setTagsByName() : void
- Set tags for an item by tag names.
- setTagsForItem() : void
- Set tags for an item (replaces existing associations).
- query() : QueryBuilder
- Get a query builder for this association's table.
Constants
ITEM_COLUMN
private
mixed
ITEM_COLUMN
= 'WtWoID'
TABLE_NAME
private
mixed
TABLE_NAME
= 'word_tag_map'
TAG_COLUMN
private
mixed
TAG_COLUMN
= 'WtTgID'
Properties
$tagRepository
private
TagRepositoryInterface
$tagRepository
Methods
__construct()
Constructor.
public
__construct(TagRepositoryInterface $tagRepository) : mixed
Parameters
- $tagRepository : TagRepositoryInterface
-
Term tag repository
addTag()
Add a tag to an item.
public
addTag(int $itemId, int $tagId) : bool
Parameters
- $itemId : int
-
The item ID
- $tagId : int
-
The tag ID
Return values
bool —True if added, false if already exists
addTagToItems()
Add a tag to multiple items.
public
addTagToItems(int $tagId, array<string|int, mixed> $itemIds) : int
Parameters
- $tagId : int
-
The tag ID
- $itemIds : array<string|int, mixed>
-
Item IDs to add the tag to
Return values
int —Number of items the tag was added to
cleanupOrphanedLinks()
Clean up orphaned tag links.
public
cleanupOrphanedLinks() : int
Return values
int —Number of removed orphaned links
clearItemsForTag()
Remove all associations for a tag.
public
clearItemsForTag(int $tagId) : int
Parameters
- $tagId : int
-
The tag ID
Return values
int —Number of removed associations
clearTagsForItem()
Remove all associations for an item.
public
clearTagsForItem(int $itemId) : int
Parameters
- $itemId : int
-
The item ID
Return values
int —Number of removed associations
getItemCount()
Get count of items associated with a tag.
public
getItemCount(int $tagId) : int
Parameters
- $tagId : int
-
The tag ID
Return values
intgetTagIdsForItem()
Get all tag IDs associated with an item.
public
getTagIdsForItem(int $itemId) : array<string|int, int>
Parameters
- $itemId : int
-
The item ID (word, text, or archived text)
Return values
array<string|int, int> —Array of tag IDs
getTagTextsForItem()
Get all tag texts associated with an item.
public
getTagTextsForItem(int $itemId) : array<string|int, string>
Parameters
- $itemId : int
-
The item ID
Return values
array<string|int, string> —Array of tag texts
hasTag()
Check if a tag is associated with an item.
public
hasTag(int $itemId, int $tagId) : bool
Parameters
- $itemId : int
-
The item ID
- $tagId : int
-
The tag ID
Return values
boolremoveTag()
Remove a tag from an item.
public
removeTag(int $itemId, int $tagId) : bool
Parameters
- $itemId : int
-
The item ID
- $tagId : int
-
The tag ID
Return values
bool —True if removed, false if not found
removeTagFromItems()
Remove a tag from multiple items.
public
removeTagFromItems(int $tagId, array<string|int, mixed> $itemIds) : int
Parameters
- $tagId : int
-
The tag ID
- $itemIds : array<string|int, mixed>
-
Item IDs to remove the tag from
Return values
int —Number of items the tag was removed from
setTagsByName()
Set tags for an item by tag names.
public
setTagsByName(int $itemId, array<string|int, mixed> $tagNames) : void
Parameters
- $itemId : int
-
The item ID
- $tagNames : array<string|int, mixed>
-
Tag names to associate
setTagsForItem()
Set tags for an item (replaces existing associations).
public
setTagsForItem(int $itemId, array<string|int, mixed> $tagIds) : void
Parameters
- $itemId : int
-
The item ID
- $tagIds : array<string|int, mixed>
-
Tag IDs to associate
query()
Get a query builder for this association's table.
private
query() : QueryBuilder