MySqlFeedRepository
extends AbstractRepository
in package
implements
FeedRepositoryInterface
MySQL repository for Feed entities.
Provides database access for feed management operations.
Tags
Table of Contents
Interfaces
- FeedRepositoryInterface
- Repository interface for Feed entities.
Properties
- $columnMap : array<string, string>
- Column mapping: entity property => database column.
- $primaryKey : string
- The primary key column name.
- $tableName : string
- The table name (without prefix).
Methods
- beginTransaction() : bool
- Begin a database transaction.
- commit() : bool
- Commit the current transaction.
- count() : int
- Count entities matching criteria.
- countFeeds() : int
- Count feeds with optional filtering.
- delete() : bool
- Delete an entity.
- deleteMultiple() : int
- Delete multiple feeds by IDs.
- exists() : bool
- Check if an entity with the given ID exists.
- find() : object|null
- Find an entity by its primary key.
- findAll() : array<string|int, Feed>
- Find all entities.
- findBy() : array<int, object>
- Find entities by criteria.
- findByLanguage() : array<string|int, Feed>
- Find feeds by language ID.
- findNeedingAutoUpdate() : array<string|int, Feed>
- Find feeds that need auto-update.
- findOneBy() : object|null
- Find a single entity by criteria.
- findPaginated() : array<string|int, Feed>
- Find feeds with pagination and filtering.
- getForSelect() : array<int, array{id: int, name: string, language_id: int}>
- Get feeds formatted for select dropdown options.
- rollback() : bool
- Rollback the current transaction.
- save() : int
- Save an entity (insert or update).
- updateTimestamp() : void
- Update the last update timestamp for a feed.
- getEntityId() : int
- Get the ID from an entity.
- mapToEntity() : object
- Map a database row to an entity object.
- mapToRow() : array<string, scalar|null>
- Map an entity to a database row.
- query() : QueryBuilder
- Get a query builder for this repository's table.
- setEntityId() : void
- Set the ID on an entity.
Properties
$columnMap
Column mapping: entity property => database column.
protected
array<string, string>
$columnMap
= ['id' => 'NfID', 'languageId' => 'NfLgID', 'name' => 'NfName', 'sourceUri' => 'NfSourceURI', 'articleSectionTags' => 'NfArticleSectionTags', 'filterTags' => 'NfFilterTags', 'updateTimestamp' => 'NfUpdate', 'options' => 'NfOptions']
Property to column mapping
$primaryKey
The primary key column name.
protected
string
$primaryKey
= 'NfID'
Primary key column
$tableName
The table name (without prefix).
protected
string
$tableName
= 'news_feeds'
Table name without prefix
Methods
beginTransaction()
Begin a database transaction.
public
beginTransaction() : bool
Return values
boolcommit()
Commit the current transaction.
public
commit() : bool
Return values
boolcount()
Count entities matching criteria.
public
count([array<string, mixed> $criteria = [] ]) : int
Parameters
- $criteria : array<string, mixed> = []
Return values
int —The count
countFeeds()
Count feeds with optional filtering.
public
countFeeds([int|null $languageId = null ][, string|null $queryPattern = null ]) : int
Parameters
- $languageId : int|null = null
-
Optional language ID filter
- $queryPattern : string|null = null
-
Optional search pattern
Return values
int —Count of matching feeds
delete()
Delete an entity.
public
delete(object|int $entityOrId) : bool
Parameters
- $entityOrId : object|int
-
The entity or its ID
Return values
bool —True if deleted, false if not found
deleteMultiple()
Delete multiple feeds by IDs.
public
deleteMultiple(array<string|int, mixed> $ids) : int
Parameters
- $ids : array<string|int, mixed>
-
Feed IDs
Return values
int —Number of feeds deleted
exists()
Check if an entity with the given ID exists.
public
exists(int $id) : bool
Parameters
- $id : int
-
The entity ID
Return values
boolfind()
Find an entity by its primary key.
public
find(int $id) : object|null
Parameters
- $id : int
-
The entity ID
Return values
object|null —The entity or null if not found
findAll()
Find all entities.
public
findAll([string $orderBy = 'NfUpdate' ][, string $direction = 'DESC' ]) : array<string|int, Feed>
Parameters
- $orderBy : string = 'NfUpdate'
- $direction : string = 'DESC'
Tags
Return values
array<string|int, Feed>findBy()
Find entities by criteria.
public
findBy(array<string, mixed> $criteria[, array<string, string>|null $orderBy = null ][, int|null $limit = null ][, int|null $offset = null ]) : array<int, object>
Parameters
- $criteria : array<string, mixed>
- $orderBy : array<string, string>|null = null
- $limit : int|null = null
-
Maximum results
- $offset : int|null = null
-
Offset for pagination
Return values
array<int, object> —Array of matching entities
findByLanguage()
Find feeds by language ID.
public
findByLanguage(int $languageId[, string $orderBy = 'NfUpdate' ][, string $direction = 'DESC' ]) : array<string|int, Feed>
Parameters
- $languageId : int
-
Language ID
- $orderBy : string = 'NfUpdate'
-
Column to order by
- $direction : string = 'DESC'
-
Sort direction
Return values
array<string|int, Feed>findNeedingAutoUpdate()
Find feeds that need auto-update.
public
findNeedingAutoUpdate(int $currentTime) : array<string|int, Feed>
Parameters
- $currentTime : int
-
Current Unix timestamp
Return values
array<string|int, Feed>findOneBy()
Find a single entity by criteria.
public
findOneBy(array<string, mixed> $criteria) : object|null
Parameters
- $criteria : array<string, mixed>
Tags
Return values
object|nullfindPaginated()
Find feeds with pagination and filtering.
public
findPaginated(int $offset, int $limit[, int|null $languageId = null ][, string|null $queryPattern = null ][, string $orderBy = 'NfUpdate' ][, string $direction = 'DESC' ]) : array<string|int, Feed>
Parameters
- $offset : int
-
Pagination offset
- $limit : int
-
Page size
- $languageId : int|null = null
-
Language filter
- $queryPattern : string|null = null
-
Name filter (LIKE pattern)
- $orderBy : string = 'NfUpdate'
-
Column to order by
- $direction : string = 'DESC'
-
Sort direction
Return values
array<string|int, Feed>getForSelect()
Get feeds formatted for select dropdown options.
public
getForSelect([int $languageId = 0 ][, int $maxNameLength = 40 ]) : array<int, array{id: int, name: string, language_id: int}>
Parameters
- $languageId : int = 0
-
Language ID (0 for all languages)
- $maxNameLength : int = 40
-
Maximum name length before truncation
Return values
array<int, array{id: int, name: string, language_id: int}>rollback()
Rollback the current transaction.
public
rollback() : bool
Return values
boolsave()
Save an entity (insert or update).
public
save(Feed $entity) : int
Parameters
- $entity : Feed
Return values
int —The entity ID (useful for inserts)
updateTimestamp()
Update the last update timestamp for a feed.
public
updateTimestamp(int $feedId, int $timestamp) : void
Parameters
- $feedId : int
-
Feed ID
- $timestamp : int
-
Unix timestamp
getEntityId()
Get the ID from an entity.
protected
getEntityId(Feed $entity) : int
Parameters
- $entity : Feed
Return values
int —The entity ID
mapToEntity()
Map a database row to an entity object.
protected
mapToEntity(array<string|int, mixed> $row) : object
Parameters
- $row : array<string|int, mixed>
-
Database row
Return values
object —The entity
mapToRow()
Map an entity to a database row.
protected
mapToRow(Feed $entity) : array<string, scalar|null>
Parameters
- $entity : Feed
Return values
array<string, scalar|null>query()
Get a query builder for this repository's table.
protected
query() : QueryBuilder
Return values
QueryBuildersetEntityId()
Set the ID on an entity.
protected
setEntityId(Feed $entity, int $id) : void
Parameters
- $entity : Feed
- $id : int
-
The ID to set