Documentation

tab_users

Class tab_users

This class represents a table of users in a database.

Table of Contents

Properties

$allowedCols  : array<string|int, mixed>
$db  : db_master

Methods

__construct()  : mixed
Constructor for the class.
__destruct()  : mixed
Destructor method to clean up any resources used by the object.
all()  : array<string|int, mixed>|bool
Retrieves all users from the database.
delete()  : bool
Deletes a row from the 'users' table based on the given value and column.
get()  : array<string|int, mixed>|bool
Retrieves a user from the database based on a specified value and column.
getall()  : array<string|int, mixed>|bool
Retrieves all users matching the specified criteria.
getview()  : array<string|int, mixed>|bool
Retrieves a specific user from the database based on the given value and column.
insert()  : string|bool
Inserts a new user into the database.
login()  : array<string|int, mixed>|bool
Login method to authenticate user credentials.
update()  : bool
Updates a row in the 'users' table based on the given column, value, and ID.

Properties

$allowedCols

protected array<string|int, mixed> $allowedCols = ['id', 'sid', 'username', 'password', 'group', 'status']

An array containing the columns allowed for processing. Use this array to define the list of allowed columns that can be used for processing or manipulation. Each element of the array represents a column name.

Example usage:

$allowedCols = ['id', 'sid', 'username', 'password', 'group', 'status'];

Note: Make sure to update the $allowedCols array according to your requirements.

Methods

__construct()

Constructor for the class.

public __construct() : mixed

Assigns the globally available database manager object to the class property.

__destruct()

Destructor method to clean up any resources used by the object.

public __destruct() : mixed

all()

Retrieves all users from the database.

public all([string $sort = 'id' ]) : array<string|int, mixed>|bool
Parameters
$sort : string = 'id'

The column name to sort the results by. Default is 'id'.

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

Returns an array of user records if at least one user is found, otherwise returns false.

delete()

Deletes a row from the 'users' table based on the given value and column.

public delete(string $val[, string $col = 'id' ]) : bool
Parameters
$val : string

The value to match in the column.

$col : string = 'id'

The column to search the value in. Default is 'id'.

Return values
bool

Returns true if the row was successfully deleted, false otherwise.

get()

Retrieves a user from the database based on a specified value and column.

public get(string $val[, string $col = 'id' ]) : array<string|int, mixed>|bool
Parameters
$val : string

The value to search for in the specified column.

$col : string = 'id'

The column name to search for the specified value. Default is 'id'.

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

Returns an array representing the user record if a user is found, otherwise returns false.

getall()

Retrieves all users matching the specified criteria.

public getall(string $val[, string $col = 'group' ]) : array<string|int, mixed>|bool
Parameters
$val : string

The value to search for in the specified column.

$col : string = 'group'

The column to search in (default: 'group').

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

Returns an array containing the matching users, or false if no users are found.

getview()

Retrieves a specific user from the database based on the given value and column.

public getview(string $val[, string $col = 'id' ]) : array<string|int, mixed>|bool
Parameters
$val : string

The value to search for in the specified column.

$col : string = 'id'

The column name to search for the specified value. Default is 'id'.

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

Returns an array containing the user record if found, otherwise returns false.

insert()

Inserts a new user into the database.

public insert(string $sid, string $username, string $pass[, string $group = '1' ][, string $status = '0' ]) : string|bool
Parameters
$sid : string

The user's sid.

$username : string

The username of the user.

$pass : string

The password of the user.

$group : string = '1'

The group of the user. Default is '1'.

$status : string = '0'

The status of the user. Default is '0'.

Return values
string|bool

Returns the ID of the inserted user if successful, otherwise returns false.

login()

Login method to authenticate user credentials.

public login(string $user, string $pass) : array<string|int, mixed>|bool
Parameters
$user : string

The username of the user.

$pass : string

The password of the user.

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

Returns an array with user details if authentication is successful, otherwise returns false.

update()

Updates a row in the 'users' table based on the given column, value, and ID.

public update(string $col, string $val, string $id) : bool
Parameters
$col : string

The column to update the value in.

$val : string

The new value to set in the column.

$id : string

The ID of the row to update.

Return values
bool

Returns true if the row was successfully updated, false otherwise.


        
On this page

Search results