Medical Appointments API

ExceptionRepository extends BaseRepository
in package

ExceptionRepository class for working with ExceptionEntity.

This repository class extends the BaseRepository and provides specific methods for interacting with the ExceptionEntity. It inherits basic CRUD operations from the BaseRepository.

Tags
extends

BaseRepository<ExceptionEntity>

author

Luis Graciano contacto@luisgraciano.dev

Table of Contents

$entity  : mixed
$fields  : array<string|int, mixed>
$primaryKey  : array<string|int, mixed>
$table  : string
__construct()  : mixed
Constructor for the ExceptionRepository.
findAll()  : array<string|int, T>
Find all entities.
findByDate()  : array<string|int, ExceptionEntity>
Find exception entities by medical center ID and date.
findByFullDay()  : ExceptionEntity|null
Find a full-day exception entity by medical center ID and date.
findById()  : T|null
Find an entity by its ID.
findByMedicalCenterId()  : array<string|int, ExceptionEntity>
Find exception entities by medical center ID.
inactiveById()  : void
Mark an exception as inactive by its ID.
save()  : T|null
Save a new entity to the database.
update()  : bool
Update an existing entity in the database.
buildEntity()  : T
Build an entity from the database row data.
fetchAll()  : array<string|int, T>
Fetch all entities based on the PDOStatement.
fetchOne()  : T|null
Fetch one entity based on the PDOStatement.
findBy()  : array<string|int, T>
Find entities based on a set of conditions.
findOne()  : T|null
Find one entity based on a specified condition.
getPDO()  : PDO
Get the PDO instance for database connection.
getPrimaryKeyCondition()  : string
Build the primary key condition for the query.
updateBy()  : bool
Update entities based on a set of conditions.
buildQuery()  : PDOStatement
Build a PDOStatement for querying the database based on the specified conditions.

Properties

$entity

protected mixed $entity

The class name of the entity that the repository works with.

$fields

protected array<string|int, mixed> $fields

The fields of the entity.

$primaryKey

protected array<string|int, mixed> $primaryKey

The primary key of the entity.

Methods

__construct()

Constructor for the ExceptionRepository.

public __construct() : mixed

Initializes the repository with the ExceptionEntity class.

Return values
mixed

findAll()

Find all entities.

public findAll([PDO|null $pdo = null ]) : array<string|int, T>
Parameters
$pdo : PDO|null = null

The PDO instance for database connection (optional).

Tags
throws
UnhandledException

If an error occurs while preparing the PDOStatement.

Return values
array<string|int, T>

An array of entities.

findByDate()

Find exception entities by medical center ID and date.

public findByDate(int $medicalCenterId, string $date) : array<string|int, ExceptionEntity>
Parameters
$medicalCenterId : int

The ID of the medical center.

$date : string

The date for which exceptions should be retrieved.

Tags
throws
UnhandledException

If an error occurs while finding the exceptions.

Return values
array<string|int, ExceptionEntity>

An array of ExceptionEntity objects matching the criteria.

findByFullDay()

Find a full-day exception entity by medical center ID and date.

public findByFullDay(int $medicalCenterId, string $date) : ExceptionEntity|null
Parameters
$medicalCenterId : int

The ID of the medical center.

$date : string

The date for which a full-day exception should be retrieved.

Tags
throws
UnhandledException

If an error occurs while finding the exception.

Return values
ExceptionEntity|null

A single ExceptionEntity object for the specified criteria or null if not found.

findById()

Find an entity by its ID.

public findById(mixed $id[, PDO|null $pdo = null ]) : T|null
Parameters
$id : mixed

The ID of the entity.

$pdo : PDO|null = null

The PDO instance for database connection (optional).

Tags
throws
UnhandledException

If an error occurs while preparing the PDOStatement.

Return values
T|null

The entity found, or null if not found.

findByMedicalCenterId()

Find exception entities by medical center ID.

public findByMedicalCenterId(int $medicalCenterId) : array<string|int, ExceptionEntity>
Parameters
$medicalCenterId : int

The ID of the medical center.

Tags
throws
UnhandledException

If an error occurs while finding the exceptions.

Return values
array<string|int, ExceptionEntity>

An array of ExceptionEntity objects for the specified medical center.

inactiveById()

Mark an exception as inactive by its ID.

public inactiveById(int $id) : void
Parameters
$id : int

The ID of the exception to mark as inactive.

Tags
throws
UnhandledException

If an error occurs while marking the exception as inactive.

Return values
void

save()

Save a new entity to the database.

public save(T $entity[, PDO|null $pdo = null ]) : T|null
Parameters
$entity : T

The entity to be saved.

$pdo : PDO|null = null

The PDO instance for database connection.

Tags
throws
UnhandledException

If an error occurs while saving the entity.

Return values
T|null

The saved entity.

update()

Update an existing entity in the database.

public update(T $entity[, PDO|null $pdo = null ]) : bool
Parameters
$entity : T

The entity to be updated.

$pdo : PDO|null = null

The PDO instance for database connection (optional).

Tags
throws
UnhandledException

If an error occurs while preparing the PDOStatement.

Return values
bool

True if the update was successful, false otherwise.

buildEntity()

Build an entity from the database row data.

protected buildEntity(array<string|int, mixed> $data) : T
Parameters
$data : array<string|int, mixed>

The associative array representing the database row data.

Return values
T

The built entity.

fetchAll()

Fetch all entities based on the PDOStatement.

protected fetchAll(PDOStatement $PDOStatement) : array<string|int, T>
Parameters
$PDOStatement : PDOStatement

The prepared PDOStatement for the query.

Return values
array<string|int, T>

An array of entities.

fetchOne()

Fetch one entity based on the PDOStatement.

protected fetchOne(PDOStatement $PDOStatement) : T|null
Parameters
$PDOStatement : PDOStatement

The prepared PDOStatement for the query.

Return values
T|null

The entity found, or null if not found.

findBy()

Find entities based on a set of conditions.

protected findBy(array<string, mixed> $where[, PDO|null $pdo = null ]) : array<string|int, T>
Parameters
$where : array<string, mixed>

An associative array of conditions for the query.

$pdo : PDO|null = null

The PDO instance for database connection (optional).

Tags
throws
UnhandledException

If an error occurs while preparing the PDOStatement.

Return values
array<string|int, T>

An array of entities.

findOne()

Find one entity based on a specified condition.

protected findOne(array<string, mixed> $where[, PDO|null $pdo = null ]) : T|null
Parameters
$where : array<string, mixed>

An associative array of conditions for the query.

$pdo : PDO|null = null

The PDO instance for database connection (optional).

Tags
throws
UnhandledException

If an error occurs while preparing the PDOStatement.

Return values
T|null

The entity found, or null if not found.

getPDO()

Get the PDO instance for database connection.

protected getPDO([PDO|null $pdo = null ]) : PDO
Parameters
$pdo : PDO|null = null

The PDO instance (optional).

Tags
throws
UnhandledException

If an error occurs while connecting to the database.

Return values
PDO

The PDO instance for database connection.

getPrimaryKeyCondition()

Build the primary key condition for the query.

protected getPrimaryKeyCondition() : string
Return values
string

The primary key condition for the query.

updateBy()

Update entities based on a set of conditions.

protected updateBy(array<string|int, mixed> $data, array<string|int, mixed> $where[, PDO|null $pdo = null ]) : bool
Parameters
$data : array<string|int, mixed>

The data to be updated.

$where : array<string|int, mixed>

Conditions for the query.

$pdo : PDO|null = null

The PDO instance for database connection (optional).

Tags
throws
UnhandledException

If an error occurs while preparing the PDOStatement.

Return values
bool

True if the update was successful, false otherwise.

buildQuery()

Build a PDOStatement for querying the database based on the specified conditions.

private buildQuery(array<string, mixed> $where[, PDO|null $pdo = null ]) : PDOStatement
Parameters
$where : array<string, mixed>

An associative array of conditions for the query.

$pdo : PDO|null = null

The PDO instance for database connection (optional).

Tags
throws
UnhandledException

If an error occurs while preparing the PDOStatement.

Return values
PDOStatement

The prepared PDOStatement for the query.

Search results