ScheduleTimeSlotRepository
extends BaseRepository
in package
ScheduleTimeSlotRepository class for working with ScheduleTimeSlotEntity.
This repository class extends the BaseRepository and provides specific methods for interacting with the ScheduleTimeSlotEntity. It inherits basic CRUD operations from the BaseRepository.
Tags
Table of Contents
- $entity : mixed
- $fields : array<string|int, mixed>
- $primaryKey : array<string|int, mixed>
- $table : string
- __construct() : mixed
- Constructor for the ScheduleTimeSlotRepository.
- countAppointments() : int
- Count appointments by schedule time slot ID and reserved status.
- findAll() : array<string|int, T>
- Find all entities.
- findById() : T|null
- Find an entity by its ID.
- findByScheduleId() : array<string|int, ScheduleTimeSlotEntity>
- Find schedule time slots by schedule ID and active status.
- inactive() : bool
- Update the active status of the schedule time slot to inactive.
- 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.
$table
protected
string
$table
The table name of the entity.
Methods
__construct()
Constructor for the ScheduleTimeSlotRepository.
public
__construct() : mixed
Initializes the repository with the ScheduleTimeSlotEntity class.
Return values
mixed —countAppointments()
Count appointments by schedule time slot ID and reserved status.
public
countAppointments(int $id) : int
Parameters
- $id : int
-
The ID of the schedule time slot to search for.
Tags
Return values
int —The number of appointments found for the given schedule time slot ID.
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
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
Return values
T|null —The entity found, or null if not found.
findByScheduleId()
Find schedule time slots by schedule ID and active status.
public
findByScheduleId(int $scheduleId) : array<string|int, ScheduleTimeSlotEntity>
Parameters
- $scheduleId : int
-
The ID of the schedule to search for.
Tags
Return values
array<string|int, ScheduleTimeSlotEntity> —An array of schedule time slots found for the given schedule ID.
inactive()
Update the active status of the schedule time slot to inactive.
public
inactive(int $id) : bool
Parameters
- $id : int
-
The ID of the schedule time slot to update.
Tags
Return values
bool —Whether the update was successful.
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
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
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
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
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
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
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
Return values
PDOStatement —The prepared PDOStatement for the query.