Documentation

MySqlArticleRepository extends AbstractRepository implements ArticleRepositoryInterface

MySQL repository for Article entities (feed_links).

Provides database access for article management operations.

Tags
extends
since
3.0.0

Table of Contents

Interfaces

ArticleRepositoryInterface
Repository interface for Article entities (feed_links).

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.
countByFeed()  : int
Count articles by feed ID.
countByFeeds()  : int
Count articles by multiple feed IDs.
delete()  : bool
Delete an entity.
deleteByFeed()  : int
Delete all articles for a feed.
deleteByFeeds()  : int
Delete all articles for multiple feeds.
deleteByIds()  : int
Delete articles 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<int, object>
Find all entities.
findBy()  : array<int, object>
Find entities by criteria.
findByFeed()  : array<string|int, Article>
Find articles by feed ID with pagination.
findByFeedsWithStatus()  : array<string|int, Article, text_id: int|null, archived_id: int|null, status: string}>
Find articles by feed IDs with status information.
findByIds()  : array<string|int, Article>
Find articles by multiple IDs.
findOneBy()  : object|null
Find a single entity by criteria.
getCountPerFeed()  : array<int, int>
Get article count per feed.
insertBatch()  : array{inserted: int, duplicates: int}
Insert multiple articles in batch.
markAsError()  : void
Mark an article as error by its link.
resetErrorsByFeeds()  : int
Reset error status for articles in feeds.
rollback()  : bool
Rollback the current transaction.
save()  : int
Save an entity (insert or update).
titleExistsForFeed()  : bool
Check if an article with the given title exists 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' => 'FlID', 'feedId' => 'FlNfID', 'title' => 'FlTitle', 'link' => 'FlLink', 'description' => 'FlDescription', 'date' => 'FlDate', 'audio' => 'FlAudio', 'text' => 'FlText']

Property to column mapping

$primaryKey

The primary key column name.

protected string $primaryKey = 'FlID'

Primary key column

$tableName

The table name (without prefix).

protected string $tableName = 'feed_links'

Table name without prefix

Methods

beginTransaction()

Begin a database transaction.

public beginTransaction() : bool
Return values
bool

commit()

Commit the current transaction.

public commit() : bool
Return values
bool

count()

Count entities matching criteria.

public count([array<string, mixed> $criteria = [] ]) : int
Parameters
$criteria : array<string, mixed> = []
Return values
int

The count

countByFeed()

Count articles by feed ID.

public countByFeed(int $feedId[, string $search = '' ]) : int
Parameters
$feedId : int

Feed ID

$search : string = ''

Search query for title/description

Return values
int

countByFeeds()

Count articles by multiple feed IDs.

public countByFeeds(array<string|int, mixed> $feedIds[, string $search = '' ]) : int
Parameters
$feedIds : array<string|int, mixed>

Feed IDs

$search : string = ''

Search query for title/description

Return values
int

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

deleteByFeed()

Delete all articles for a feed.

public deleteByFeed(int $feedId) : int
Parameters
$feedId : int

Feed ID

Return values
int

Number of deleted articles

deleteByFeeds()

Delete all articles for multiple feeds.

public deleteByFeeds(array<string|int, mixed> $feedIds) : int
Parameters
$feedIds : array<string|int, mixed>

Feed IDs

Return values
int

Number of deleted articles

deleteByIds()

Delete articles by IDs.

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

Article IDs

Return values
int

Number of deleted articles

exists()

Check if an entity with the given ID exists.

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

The entity ID

Return values
bool

find()

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() : array<int, object>
Return values
array<int, object>

Array of entities

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

findByFeed()

Find articles by feed ID with pagination.

public findByFeed(int $feedId[, int $offset = 0 ][, int $limit = 50 ][, string $orderBy = 'FlDate' ][, string $direction = 'DESC' ]) : array<string|int, Article>
Parameters
$feedId : int

Feed ID

$offset : int = 0

Pagination offset

$limit : int = 50

Page size

$orderBy : string = 'FlDate'

Column to order by

$direction : string = 'DESC'

Sort direction

Return values
array<string|int, Article>

findByFeedsWithStatus()

Find articles by feed IDs with status information.

public findByFeedsWithStatus(array<string|int, mixed> $feedIds[, int $offset = 0 ][, int $limit = 50 ][, string $orderBy = 'FlDate' ][, string $direction = 'DESC' ][, string $search = '' ]) : array<string|int, Article, text_id: int|null, archived_id: int|null, status: string}>
Parameters
$feedIds : array<string|int, mixed>

Feed IDs

$offset : int = 0

Pagination offset

$limit : int = 50

Page size

$orderBy : string = 'FlDate'

Column to order by

$direction : string = 'DESC'

Sort direction

$search : string = ''

Search query for title/description

Return values
array<string|int, Article, text_id: int|null, archived_id: int|null, status: string}>

findByIds()

Find articles by multiple IDs.

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

Article IDs

Return values
array<string|int, Article>

findOneBy()

Find a single entity by criteria.

public findOneBy(array<string, mixed> $criteria) : object|null
Parameters
$criteria : array<string, mixed>
Tags
psalm-suppress

InvalidReturnStatement

psalm-return

T|null

Return values
object|null

getCountPerFeed()

Get article count per feed.

public getCountPerFeed([array<string|int, mixed> $feedIds = [] ]) : array<int, int>
Parameters
$feedIds : array<string|int, mixed> = []

Feed IDs (empty for all feeds)

Return values
array<int, int>

Map of feed ID to article count

insertBatch()

Insert multiple articles in batch.

public insertBatch(array<string|int, mixed> $articles, int $feedId) : array{inserted: int, duplicates: int}
Parameters
$articles : array<string|int, mixed>

Articles to insert

$feedId : int

Feed ID for all articles

Return values
array{inserted: int, duplicates: int}

markAsError()

Mark an article as error by its link.

public markAsError(string $link) : void
Parameters
$link : string

Article link

resetErrorsByFeeds()

Reset error status for articles in feeds.

public resetErrorsByFeeds(array<string|int, mixed> $feedIds) : int
Parameters
$feedIds : array<string|int, mixed>

Feed IDs

Return values
int

Number of reset articles

rollback()

Rollback the current transaction.

public rollback() : bool
Return values
bool

titleExistsForFeed()

Check if an article with the given title exists for a feed.

public titleExistsForFeed(int $feedId, string $title) : bool
Parameters
$feedId : int

Feed ID

$title : string

Article title

Return values
bool

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(Article $entity) : array<string, scalar|null>
Parameters
$entity : Article
Return values
array<string, scalar|null>

        
On this page

Search results