tab_menue
in package
Class tab_menue
Represents a menu table in a database.
Table of Contents
Properties
- $allowedCols : array<string|int, string>
- Array containing the allowed columns for a table.
- $db : db_master
- Database connection.
Methods
- __construct() : void
- Constructor for the class.
- __destruct() : mixed
- Clean up resources and perform necessary cleanup tasks before the object is destroyed.
- all() : array<string|int, mixed>|bool
- Retrieves all records from the "menu" table based on the given sorting and direction parameters.
- delete() : bool
- Deletes a record from the `menue` table based on the specified value and column.
- get() : array<string|int, mixed>|bool
- Retrieves a record from the "menu" table based on the given value and column.
- getall() : array<string|int, mixed>|bool
- Retrieves all records from the "menue" table based on the provided column and value.
- insert() : string|bool
- Insert a new record into the "menue" table.
- update() : bool
- Updates a record in the `menue` table based on the specified column, value, and menu ID.
Properties
$allowedCols
Array containing the allowed columns for a table.
protected
array<string|int, string>
$allowedCols
= ['id', 'module', 'page', 'icon', 'parent', 'sort', 'is_admin']
Tags
$db
Database connection.
protected
db_master
$db
This variable represents the connection to the database. It is responsible for establishing and maintaining the connection, executing queries, and retrieving results from the database.
Methods
__construct()
Constructor for the class.
public
__construct() : void
__destruct()
Clean up resources and perform necessary cleanup tasks before the object is destroyed.
public
__destruct() : mixed
all()
Retrieves all records from the "menu" table based on the given sorting and direction parameters.
public
all([string $sort = 'parent' ][, string $dir = 'ASC' ]) : array<string|int, mixed>|bool
Parameters
- $sort : string = 'parent'
-
(optional) The column to sort the records by. Default is 'parent'.
- $dir : string = 'ASC'
-
(optional) The sorting direction. Default is 'ASC'.
Return values
array<string|int, mixed>|bool —An array of records if there are any, false otherwise.
delete()
Deletes a record from the `menue` table based on the specified value and column.
public
delete(string $val[, string $col = 'id' ]) : bool
Parameters
- $val : string
-
The value to use for filtering the records.
- $col : string = 'id'
-
The column to use for filtering the records. Default value is 'id'.
Return values
bool —Returns true if the record is successfully deleted, false otherwise.
get()
Retrieves a record from the "menu" table based on the given 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'
-
(optional) The column to search in. Default is 'id'.
Return values
array<string|int, mixed>|bool —The first matching record if found, false otherwise.
getall()
Retrieves all records from the "menue" table based on the provided column and value.
public
getall(string $col, string $val) : array<string|int, mixed>|bool
Parameters
- $col : string
-
The column name to search for. If not found in the allowed columns, defaults to 'id'.
- $val : string
-
The value to search for in the specified column.
Return values
array<string|int, mixed>|bool —Returns an array of database records if found, otherwise returns false.
insert()
Insert a new record into the "menue" table.
public
insert(string $mod, string $pg, string $icon, string $parent, string $sort, string $is_admin) : string|bool
Parameters
- $mod : string
-
The value of the "module" column.
- $pg : string
-
The value of the "page" column.
- $icon : string
- $parent : string
-
The value of the "parent" column.
- $sort : string
-
The value of the "sort" column.
- $is_admin : string
Return values
string|bool —Returns the last inserted ID if the insert is successful, otherwise returns false.
update()
Updates a record in the `menue` table based on the specified column, value, and menu ID.
public
update(string $col, string $val, string $mid) : bool
Parameters
- $col : string
-
The column to update.
- $val : string
-
The new value for the specified column.
- $mid : string
-
The ID of the menu record to update.
Return values
bool —Returns true if the record is successfully updated, false otherwise.