tab_users_tenants
in package
Class tab_users_tenants
Represents a database table "users_tenants" and provides methods for interacting with the table.
Table of Contents
Properties
- $allowedCols : array<string|int, string>
- Declares an array of allowed column names.
- $db : db_master
Methods
- __construct() : void
- Initializes a new instance of the class.
- __destruct() : void
- Destructor method for cleaning up class resources
- delete() : bool
- Deletes a record from the database table based on a specified value and column.
- get() : array<string|int, mixed>|bool
- Retrieves a record from the "users_tenants" table based on a specified value
- getalltenants() : array<string|int, mixed>|bool
- Retrieves all tenants associated with a user from the `users_tenants` table.
- insert() : bool
- Inserts a new record into the `users_tenants` table.
- update() : bool
- Updates a record in the database table based on a specified column and value.
Properties
$allowedCols
Declares an array of allowed column names.
protected
array<string|int, string>
$allowedCols
= ['id', 'user', 'tenant', 'access']
The array containing the allowed column names.
$db
protected
db_master
$db
Methods
__construct()
Initializes a new instance of the class.
public
__construct() : void
__destruct()
Destructor method for cleaning up class resources
public
__destruct() : void
delete()
Deletes a record from the database table based on a specified value and column.
public
delete(string $val[, string $col = 'uid' ]) : bool
Parameters
- $val : string
-
The value to search for in the specified column.
- $col : string = 'uid'
-
The column to search in. Defaults to 'uid' if not specified.
Return values
bool —Returns true if the record was successfully deleted, false otherwise.
get()
Retrieves a record from the "users_tenants" table based on a specified value
public
get(string $val[, string $col = 'uid' ]) : array<string|int, mixed>|bool
Parameters
- $val : string
-
The value to search for in the specified column (default is "uid")
- $col : string = 'uid'
-
The column to search in (default is "uid")
Return values
array<string|int, mixed>|bool —Returns an array if the record is found, otherwise returns false
getalltenants()
Retrieves all tenants associated with a user from the `users_tenants` table.
public
getalltenants(string $uid) : array<string|int, mixed>|bool
Parameters
- $uid : string
-
The uid of the user.
Return values
array<string|int, mixed>|bool —Returns an array of records if tenants are found, otherwise false.
insert()
Inserts a new record into the `users_tenants` table.
public
insert(string $uid, string $tenant, string $access) : bool
Parameters
- $uid : string
-
The uid of the user.
- $tenant : string
-
The tenant.
- $access : string
-
The access level.
Return values
bool —Returns true if the record is successfully inserted, otherwise false.
update()
Updates a record in the database table based on a specified column and value.
public
update(string $col, string $val, string $uid) : bool
The update is performed on the record with the specified uid.
Parameters
- $col : string
-
The column to update.
- $val : string
-
The new value for the specified column.
- $uid : string
-
The uid of the record to update.
Return values
bool —Returns true if the record was successfully updated, false otherwise.