Documentation

tab_api

Class tab_api

Represents an API table and provides methods to perform CRUD operations on the table.

Table of Contents

Properties

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

Methods

__construct()  : void
Constructor for the class.
__destruct()  : void
Destructor method for the class.
all()  : array<string|int, mixed>|bool
Retrieves all records from the 'api' table.
delete()  : bool
Deletes a record from the 'api' table based on the given value and column.
get()  : array<string|int, mixed>|bool
Retrieves a specific record from the 'api' table based on the given value and column.
insert()  : bool
Inserts a new record into the 'api' table with the provided api key and tenant.
update()  : bool
Updates a record in the 'api' table with the given value for the specified column, based on the provided ID.

Properties

$allowedcols

protected array<string|int, mixed> $allowedcols = ['id', 'apikey', 'tenant', 'token']

Array containing a list of allowed column names. This is used to specify the columns that are allowed when performing a certain operation on a dataset. Each element in the array represents the name of a column that is allowed.

Example usage: $allowedcols = ['id', 'apikey', 'tenant', 'token'];

Tags
see
SomeOperation::validateCols()

Method where this array is used to validate columns.

see
AnotherOperation::filterCols()

Method where this array is used to filter columns.

Methods

__construct()

Constructor for the class.

public __construct() : void

Initializes the instance of the class by assigning the provided database manager instance to the internal $db property.

__destruct()

Destructor method for the class.

public __destruct() : void

This method is automatically called when an object is destroyed, and it is responsible for cleaning up any resources used by the object. In this case, it unsets the $db property, effectively releasing any database connections or resources held by the object.

all()

Retrieves all records from the 'api' table.

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

The column name to sort the records by. Defaults to 'tenant' if column is not in the allowed columns.

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

Returns an array of all records if any records are found, or false if no records are found.

delete()

Deletes a record from the 'api' 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 specified column.

$col : string = 'id'

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

Return values
bool

Returns true if a record is deleted successfully, otherwise false.

get()

Retrieves a specific record from the 'api' table based on the given value and column.

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

The value to search for in the specified column.

$col : string = 'apikey'

The column name to search in. Defaults to 'apikey' if column is not in the allowed columns.

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

Returns an array containing the record if found, or false if no matching record is found.

insert()

Inserts a new record into the 'api' table with the provided api key and tenant.

public insert(string $apikey, string $tenant) : bool
Parameters
$apikey : string

The api key to insert.

$tenant : string

The tenant to insert.

Return values
bool

Returns true if the record was successfully inserted, false otherwise.

update()

Updates a record in the 'api' table with the given value for the specified column, based on the provided ID.

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

The column to update with the new value.

$val : string

The new value to set in the specified column.

$id : string

The ID of the record to be updated.

Return values
bool

Returns true if the record is updated successfully, otherwise false.


        
On this page

Search results