Documentation

EventRegistrationRepository
in package

EventRegistrationRepository - Event Registration Data Access

Manages event registration data in the EVENT_REGISTRATIONS table. Handles user registration and unregistration for events.

Features:

  • Check if user is registered to an event
  • Register user to an event
  • Unregister user from an event
Tags
version
1.0.0
author

BdeLive - Group 8

Table of Contents

Properties

$pdo  : PDO
PDO database connection instance

Methods

__construct()  : void
Constructor - Initialize database connection
addUserToGroup()  : bool
Add a user to a group event with team assignment
changeUserTeam()  : bool
Move a user to a different team within the same event
deleteGroupRegistrants()  : int
Delete all registrations for a specific team in an event
deleteRegistrationsByEvent()  : int
Delete all registrations for an event
deleteRegistrationsByTeam()  : int
Delete all registrations for a specific team
getGroupRegistrantsForEvent()  : array<int, array<int, array<string, mixed>>>
Get group registrants for an event, grouped by team number
getIndividualRegistrantsForEvent()  : array<int, array{user_id: int, first_name: string, last_name: string, promotion: string, registration_date: string}>
Get individual registrations for an event
getRegisteredUsersDetails()  : array<int, array{first_name: string, last_name: string, user_status: string, email: string}>
Retrieves detailed information about users registered for a specific event.
getRegisteredUsersGroupedForPdf()  : array{individual: array>, teams: array>}
Get registered users grouped by team for PDF export
getRegisteredUsersWithTeams()  : array<int, array<string, mixed>>
Get registered users grouped by team for an event
getRegistrationsByEventId()  : array<int, array{firstname: string, lastname: string, email: string, registration_date: string}>
Get registrations by event ID
getTeamIdByUserAndEvent()  : int|null
Get team ID for a user in a specific event
getTeamMemberCount()  : int
Get the number of members in a team
isUserRegistered()  : bool
Check if a user is registered for an event
registerUser()  : bool
Register a user to an event
registerUsers()  : int
Register multiple users to an event in a single operation
registerUserWithTeam()  : bool
Register a user to an event as part of a team
removeUserFromGroup()  : bool
Remove a user from a group event registration
searchUsersNotRegistered()  : array<int, array{user_id: int, first_name: string, last_name: string, user_status: string}>
Search users not registered to a specific event
unregisterUser()  : bool
Unregister a user from an event
unregisterUserFromFutureEvents()  : int
Unregister a user from all future events
unregisterUsers()  : int
Batch unregister multiple users from an event

Properties

Methods

__construct()

Constructor - Initialize database connection

public __construct() : void

Retrieves the database connection from the Database singleton.

addUserToGroup()

Add a user to a group event with team assignment

public addUserToGroup(int $eventId, int $userId, int $teamId) : bool

Creates a registration record with team_id. Uses INSERT IGNORE to skip if user is already registered.

Parameters
$eventId : int

The event identifier

$userId : int

The user identifier

$teamId : int

The team identifier

Return values
bool

True if registration created

changeUserTeam()

Move a user to a different team within the same event

public changeUserTeam(int $eventId, int $userId, int $newTeamId) : bool

Updates the team_id in the registration record.

Parameters
$eventId : int

The event identifier

$userId : int

The user identifier

$newTeamId : int

The new team identifier

Return values
bool

True if update successful

deleteGroupRegistrants()

Delete all registrations for a specific team in an event

public deleteGroupRegistrants(int $eventId, int $teamId) : int

Removes all member registrations associated with a team_id within the given event.

Parameters
$eventId : int

The event identifier

$teamId : int

The team identifier

Return values
int

Number of registrations deleted

deleteRegistrationsByEvent()

Delete all registrations for an event

public deleteRegistrationsByEvent(int $eventId) : int

Used when event type or team size changes to clear all existing registrations.

Parameters
$eventId : int

The event identifier

Return values
int

Number of registrations deleted

deleteRegistrationsByTeam()

Delete all registrations for a specific team

public deleteRegistrationsByTeam(int $teamId) : int

Removes all member registrations associated with a team.

Parameters
$teamId : int

The team identifier

Return values
int

Number of registrations deleted

getGroupRegistrantsForEvent()

Get group registrants for an event, grouped by team number

public getGroupRegistrantsForEvent(int $eventId) : array<int, array<int, array<string, mixed>>>

Retrieves the list of users registered in teams for a group event. Results are grouped by team_number for display with group headers. Includes first name, last name, promotion (status), and registration date.

Parameters
$eventId : int

The event identifier

Return values
array<int, array<int, array<string, mixed>>>

getIndividualRegistrantsForEvent()

Get individual registrations for an event

public getIndividualRegistrantsForEvent(int $eventId) : array<int, array{user_id: int, first_name: string, last_name: string, promotion: string, registration_date: string}>

Retrieves the list of users registered individually to an event. Includes user ID, first name, last name, promotion (status), and registration date. Join with USERS table to get user details.

Parameters
$eventId : int

The event identifier

Return values
array<int, array{user_id: int, first_name: string, last_name: string, promotion: string, registration_date: string}>

getRegisteredUsersDetails()

Retrieves detailed information about users registered for a specific event.

public getRegisteredUsersDetails(int $eventId) : array<int, array{first_name: string, last_name: string, user_status: string, email: string}>

This method joins the USERS table with the EVENT_REGISTRATIONS table to provide a list of participant names, statuses, and contact information.

Parameters
$eventId : int

The unique identifier of the event.

Return values
array<int, array{first_name: string, last_name: string, user_status: string, email: string}>

An indexed array of associative arrays containing user details.

getRegisteredUsersGroupedForPdf()

Get registered users grouped by team for PDF export

public getRegisteredUsersGroupedForPdf(int $eventId) : array{individual: array>, teams: array>}

Returns an array with 'individual' and 'teams' keys

Parameters
$eventId : int

The event identifier

Return values
array{individual: array>, teams: array>}

getRegisteredUsersWithTeams()

Get registered users grouped by team for an event

public getRegisteredUsersWithTeams(int $eventId) : array<int, array<string, mixed>>

Returns individual registrations (team_id IS NULL) followed by team registrations grouped by team number.

Parameters
$eventId : int

The event identifier

Return values
array<int, array<string, mixed>>

Array of registrations with team info

getRegistrationsByEventId()

Get registrations by event ID

public getRegistrationsByEventId(int $eventId) : array<int, array{firstname: string, lastname: string, email: string, registration_date: string}>
Parameters
$eventId : int

The event identifier

Return values
array<int, array{firstname: string, lastname: string, email: string, registration_date: string}>

getTeamIdByUserAndEvent()

Get team ID for a user in a specific event

public getTeamIdByUserAndEvent(int $userId, int $eventId) : int|null

Checks if the user is part of a team for the given event.

Parameters
$userId : int

The user identifier

$eventId : int

The event identifier

Return values
int|null

Team ID if user is in a team, null otherwise

getTeamMemberCount()

Get the number of members in a team

public getTeamMemberCount(int $teamId) : int
Parameters
$teamId : int

The team identifier

Return values
int

Number of members in the team

isUserRegistered()

Check if a user is registered for an event

public isUserRegistered(int $eventId, int $userId) : bool

Queries the EVENT_REGISTRATIONS table to verify if a registration exists.

Parameters
$eventId : int

The event identifier

$userId : int

The user identifier

Return values
bool

True if user is registered, false otherwise

registerUser()

Register a user to an event

public registerUser(int $eventId, int $userId) : bool

Creates a new registration record with "Confirmé" status. Does not check for duplicates - use isUserRegistered() first.

Parameters
$eventId : int

The event identifier

$userId : int

The user identifier

Return values
bool

True if registration successful, false otherwise

registerUsers()

Register multiple users to an event in a single operation

public registerUsers(int $eventId, array<int, int> $userIds) : int

Inserts registration records for the given user IDs. Uses INSERT IGNORE to gracefully skip users who are already registered.

Parameters
$eventId : int

The event identifier

$userIds : array<int, int>

Array of user identifiers to register

Return values
int

Number of registrations successfully created

registerUserWithTeam()

Register a user to an event as part of a team

public registerUserWithTeam(int $eventId, int $userId, int $teamId) : bool

Creates a new registration record with team association.

Parameters
$eventId : int

The event identifier

$userId : int

The user identifier

$teamId : int

The team identifier

Return values
bool

True if registration successful, false otherwise

removeUserFromGroup()

Remove a user from a group event registration

public removeUserFromGroup(int $eventId, int $userId) : bool

Deletes the registration record for the user in the given event.

Parameters
$eventId : int

The event identifier

$userId : int

The user identifier

Return values
bool

True if deletion successful

searchUsersNotRegistered()

Search users not registered to a specific event

public searchUsersNotRegistered(int $eventId, string $query[, int $limit = 20 ]) : array<int, array{user_id: int, first_name: string, last_name: string, user_status: string}>

Returns users matching the search query who are not yet registered for the given event. Automatically detects search mode:

  • Numeric query: searches by exact user_id
  • Text query: searches by first_name or last_name using LIKE

Uses LEFT JOIN anti-pattern instead of NOT IN for reliability with native prepared statements (EMULATE_PREPARES = false).

Parameters
$eventId : int

The event identifier

$query : string

The search query (name or user_id)

$limit : int = 20

Maximum number of results (default 20)

Return values
array<int, array{user_id: int, first_name: string, last_name: string, user_status: string}>

Matching users

unregisterUser()

Unregister a user from an event

public unregisterUser(int $eventId, int $userId) : bool

Deletes the registration record from the EVENT_REGISTRATIONS table.

Parameters
$eventId : int

The event identifier

$userId : int

The user identifier

Return values
bool

True if unregistration successful, false otherwise

unregisterUserFromFutureEvents()

Unregister a user from all future events

public unregisterUserFromFutureEvents(int $userId) : int

Deletes all registration records for events whose date is today or later. Intended to be called when a user account is soft-deleted, to free up spots in upcoming events.

Parameters
$userId : int

The user identifier

Return values
int

Number of registrations removed

unregisterUsers()

Batch unregister multiple users from an event

public unregisterUsers(int $eventId, array<int, int> $userIds) : int

Deletes registration records for the given user IDs from the EVENT_REGISTRATIONS table. Uses parameterized IN clause for safe batch deletion.

Parameters
$eventId : int

The event identifier

$userIds : array<int, int>

Array of user identifiers to unregister

Return values
int

Number of registrations successfully deleted


        
On this page

Search results