Repository
in package
Table of Contents
Properties
- $conn : mixed
Methods
- __construct() : mixed
- deleteUser() : mixed
- Deletes a user from the database.
- getPollById() : Poll|null
- Retrieves a poll by its ID.
- getPollOptionsByPollId() : array<string|int, mixed>|null
- Retrieves poll options by poll ID.
- getPolls() : array<string|int, mixed>|null
- Retrieves a list of polls from the database.
- getUserById() : User|null
- Retrieves a user by their ID.
- getUserByUsername() : User|null
- Retrieves a user by their username.
- getUsernameAvailability() : int
- Retrieves a amount of users with the desired username.
- getUsers() : array<string|int, User>|null
- Retrieves a list of users from the database.
- getUserStats() : array<string|int, mixed>
- Retrieves user's statistics by their ID.
- getUserVote() : int|bool
- Retreives User's vote in a specified Poll.
- getVotesByPollId() : array<string|int, mixed>|null
- Retrieves votes associated with a specific poll ID.
- insertPoll() : int
- Inserts a new poll into the database.
- insertPollOptions() : mixed
- Inserts a batch of pollOptions into the database.
- insertUser() : int
- Inserts a new user into the database.
- insertVote() : int
- Inserts a new vote into the database.
- searchPolls() : array<string|int, mixed>|null
- Searches for polls based on the user's query.
- updateUser() : mixed
- Updates a user in the database.
Properties
$conn
private
mixed
$conn
Methods
__construct()
public
__construct(mixed $conn) : mixed
Parameters
- $conn : mixed
deleteUser()
Deletes a user from the database.
public
deleteUser(User $id) : mixed
Parameters
- $id : User
-
The ID of the users to be deleted.
Tags
getPollById()
Retrieves a poll by its ID.
public
getPollById(int $id) : Poll|null
Parameters
- $id : int
-
The ID of the poll to retrieve.
Tags
Return values
Poll|null —The Poll object corresponding to the given ID.
getPollOptionsByPollId()
Retrieves poll options by poll ID.
public
getPollOptionsByPollId(int $pollId) : array<string|int, mixed>|null
Parameters
- $pollId : int
-
The ID of the poll.
Tags
Return values
array<string|int, mixed>|null —An array of PollOption objects representing the poll options or null if no polls are found or an error occurs.
getPolls()
Retrieves a list of polls from the database.
public
getPolls([int $limit = 10 ][, int $offset = 0 ][, string $filter = "1=1" ][, string $order = "id" ]) : array<string|int, mixed>|null
Parameters
- $limit : int = 10
-
The maximum number of polls to retrieve. Default is 10.
- $offset : int = 0
-
The number of polls to skip before starting to retrieve. Default is 0.
- $filter : string = "1=1"
-
Additional SQL condition.
- $order : string = "id"
-
Column name to order by. Default is id.
Tags
Return values
array<string|int, mixed>|null —An array of Poll objects if successful, or null if no polls are found or an error occurs.
getUserById()
Retrieves a user by their ID.
public
getUserById(int $id) : User|null
Parameters
- $id : int
-
The ID of the user to retrieve.
Tags
Return values
User|null —The User object if found, null if not found.
getUserByUsername()
Retrieves a user by their username.
public
getUserByUsername(string $username) : User|null
Parameters
- $username : string
-
The username of the user to retrieve.
Tags
Return values
User|null —The User object if found, null otherwise.
getUsernameAvailability()
Retrieves a amount of users with the desired username.
public
getUsernameAvailability(int $username) : int
Parameters
- $username : int
-
The desider username.
Tags
Return values
int —Amount of users with such username, 0 if none.
getUsers()
Retrieves a list of users from the database.
public
getUsers([int $limit = 10 ][, int $offset = 0 ]) : array<string|int, User>|null
Parameters
- $limit : int = 10
-
The maximum number of users to retrieve. Default is 10.
- $offset : int = 0
-
The number of users to skip before starting to collect the result set. Default is 0.
Tags
Return values
array<string|int, User>|null —An array of User objects or null if no users are found.
getUserStats()
Retrieves user's statistics by their ID.
public
getUserStats(int $id) : array<string|int, mixed>
Parameters
- $id : int
Tags
Return values
array<string|int, mixed> —Associative array of stats.
getUserVote()
Retreives User's vote in a specified Poll.
public
getUserVote(int $userId, int $pollId) : int|bool
Parameters
- $userId : int
-
The ID of the user.
- $pollId : int
-
The ID of the poll.
Tags
Return values
int|bool —ID of the chosen answer if the user has voted, false otherwise.
getVotesByPollId()
Retrieves votes associated with a specific poll ID.
public
getVotesByPollId(int $pollId) : array<string|int, mixed>|null
This method is not implemented yet!
Parameters
- $pollId : int
-
The ID of the poll for which votes are to be retrieved.
Tags
Return values
array<string|int, mixed>|null —An array of Vote objects if votes are found, null otherwise.
insertPoll()
Inserts a new poll into the database.
public
insertPoll(Poll $poll) : int
Parameters
- $poll : Poll
-
An instance of the Poll class containing details.
Tags
Return values
int —The ID of the newly inserted poll.
insertPollOptions()
Inserts a batch of pollOptions into the database.
public
insertPollOptions(array<string|int, mixed> $pollOptions) : mixed
Parameters
- $pollOptions : array<string|int, mixed>
-
An array of instances of the PollOptions class containing pollOptions details.
Tags
insertUser()
Inserts a new user into the database.
public
insertUser(User $user) : int
Parameters
- $user : User
-
An instance of the User class containing user details.
Tags
Return values
int —The ID of the newly inserted user.
insertVote()
Inserts a new vote into the database.
public
insertVote(vote $vote) : int
Parameters
- $vote : vote
-
An instance of the Vote class containing vote details.
Tags
Return values
int —The ID of the newly inserted vote.
searchPolls()
Searches for polls based on the user's query.
public
searchPolls(string $userQuery[, int $limit = 3 ][, int $offset = 0 ]) : array<string|int, mixed>|null
Parameters
- $userQuery : string
-
The search query provided by the user.
- $limit : int = 3
-
The maximum number of results to return. Default is 3.
- $offset : int = 0
-
The number of results to skip before starting to collect the result set. Default is 0.
Tags
Return values
array<string|int, mixed>|null —An array of Poll objects if results are found, null otherwise.
updateUser()
Updates a user in the database.
public
updateUser(User $user) : mixed
Parameters
- $user : User
-
An instance of the User class containing user details.