Medical Appointments API

AppointmentDurationRepository extends BaseRepository
in package

AppointmentDurationRepository class for working with AppointmentDurationEntity.

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

Tags
extends

BaseRepository<AppointmentDurationEntity>

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 AppointmentDurationRepository.
findAll()  : array<string|int, T>
Find all entities.
findById()  : T|null
Find an entity 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 AppointmentDurationRepository.

public __construct() : mixed

Initializes the repository with the AppointmentDurationEntity 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.

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.

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