userIdExists (function)

Last updated: Tue, Oct 31, 2023 2:17 pm
Return to Knowledgebase

Purpose

check whether a user with a specific ID exists in the database

Location

users/helpers/users.php

Parameters

# Parameter Data Type Required Description
1 $id integer Yes The ID of the user that needs to be checked for existence.

Returns

Data Type Description of Returned Data
bool "true" if there is a user with the provided ID; otherwise "false"

Further Documentation:

1. Checks records from the users table where the ID matches the provided ID.
2. Counts the number of rows returned by the query.
3. If the count is exactly 1, it indicates that a user with the provided ID exists, so it returns true; otherwise, it returns false.


$f = userIdExists(5);
var_dump($f); // bool(true)