Documentation

tab_modules

Class tab_modules

This class represents a module table in the database.

Table of Contents

Properties

$allowedCols  : array<string|int, mixed>
$db  : db_master
The database connection object.

Methods

__construct()  : void
Constructs a new instance of the class.
__destruct()  : void
Destructor method for the class.
all()  : array<string|int, mixed>|bool
Retrieve all modules from the database.
delete()  : bool
Deletes a record from the 'modules' table based on the specified value and column.
get()  : array<string|int, mixed>|bool
Retrieves a module from the database based on the specified value and column.
insert()  : string|bool
Inserts a new module into the database.
update()  : bool
Updates a record in the 'modules' table based on the specified column, value, and ID.

Properties

$allowedCols

protected array<string|int, mixed> $allowedCols = ['id', 'name', 'path', 'active']

Array that contains the allowed column names.

Methods

__construct()

Constructs a new instance of the class.

public __construct() : void

This method initializes the object by assigning the provided database manager instance to the class property.

__destruct()

Destructor method for the class.

public __destruct() : void

This method is automatically called when the object is destroyed or the script execution ends. It releases the references to the objects that are held by the class.

all()

Retrieve all modules from the database.

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

[optional] The column to sort by. Defaults to 'active'.

$dir : string = 'DESC'

[optional] The sorting order. Defaults to 'DESC'.

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

Returns an array of modules if successful, or false if no modules found.

delete()

Deletes a record from the 'modules' table based on the specified value and column.

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

The value to search for in the specified column. It will be escaped before use in the query.

$col : string = 'id'

The name of the column to search in. Defaults to 'id' if not specified. If the specified column is not allowed, 'id' will be used instead.

Return values
bool

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

get()

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

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

The value to match in the specified column.

$col : string = 'id'

The column to search for the specified value. Defaults to 'id' if the specified column is not allowed.

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

Returns an array representing the module if it exists, otherwise returns false.

insert()

Inserts a new module into the database.

public insert(string $name, string $path[, string $active = '0' ]) : string|bool
Parameters
$name : string

The name of the module.

$path : string

The path of the module.

$active : string = '0'

The active status of the module. Defaults to '0'.

Return values
string|bool

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

update()

Updates a record in the 'modules' table based on the specified column, value, and ID.

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

The name of the column to update. If the specified column is not allowed, 'name' will be used instead. It will be escaped before use in the query.

$val : string

The new value to set in the specified column. It will be escaped before use in the query.

$id : string

The ID of the record to update. It will be escaped before use in the query.

Return values
bool

Returns true if a record was successfully updated, otherwise false.


        
On this page

Search results