Documentation

main

Class main

Provides methods for interacting with the tab_api object.

Table of Contents

Properties

$tapi  : tab_api

Methods

__construct()  : void
Initializes a new instance of the class and creates a new `tab_api` object.
__destruct()  : void
Destructor method for the class.
all()  : array<string|int, mixed>|bool
Retrieves all the data from the `tapi` object based on the specified sort criteria.
delete()  : bool
Deletes a record from the database based on a given value and column.
generateanswer()  : array<string|int, mixed>
Generates an answer with the given status and response.
generateapikey()  : string
Generates a random API key.
get()  : array<string|int, mixed>|bool
Retrieves a specific value from the `tapi` object based on the specified column and value.
insert()  : bool
Inserts a new record into the database.
regenerateapikey()  : string|false
Regenerates the API key for a given ID.
update()  : bool
Updates a specific value in a record.

Properties

Methods

__construct()

Initializes a new instance of the class and creates a new `tab_api` object.

public __construct() : void

__destruct()

Destructor method for the class.

public __destruct() : void

This method is automatically called when an instance of the class is destroyed or no longer in use. It performs the necessary cleanup by unsetting the 'tapi' property.

all()

Retrieves all the data from the `tapi` object based on the specified sort criteria.

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

The sort criteria used to retrieve the data. The default value is 'tenant'.

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

Returns an array containing the retrieved data if successful, otherwise returns a boolean value indicating failure.

delete()

Deletes a record from the database based on a given value and column.

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

The value to delete.

$col : string = 'id'

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

Return values
bool

Whether the deletion was successful or not.

generateanswer()

Generates an answer with the given status and response.

public generateanswer(string|int $status, bool|string|array<string|int, mixed>|object $response) : array<string|int, mixed>
Parameters
$status : string|int

The status of the answer.

$response : bool|string|array<string|int, mixed>|object

The response of the answer.

Return values
array<string|int, mixed>

The generated answer, containing the status and response.

generateapikey()

Generates a random API key.

public generateapikey() : string
Return values
string

The generated API key.

get()

Retrieves a specific value from the `tapi` object based on the specified column and value.

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

The value used to retrieve the data.

$col : string = 'apikey'

The column used to retrieve the data. The default value is 'apikey'.

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

Returns an array containing the retrieved data if successful, otherwise returns a boolean value indicating failure.

insert()

Inserts a new record into the database.

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

The API key to be inserted.

$tenant : string

The tenant associated with the API key.

Return values
bool

Indicates if the insertion was successful or not.

regenerateapikey()

Regenerates the API key for a given ID.

public regenerateapikey(string $id) : string|false
Parameters
$id : string

The ID for which to regenerate the API key.

Return values
string|false

The regenerated API key if successful, false otherwise.

update()

Updates a specific value in a record.

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

The name of the column to be updated.

$val : string

The new value for the specified column.

$id : string

The identifier of the record to be updated.

Return values
bool

True if the update was successful, false otherwise.


        
On this page

Search results