tab_pages
in package
Class tab_pages
Represents a collection of methods for interacting with the "pages" table in the database.
Table of Contents
Properties
- $allowedCols : array<string|int, mixed>
- $db : db_master
- Database connection object.
Methods
- __construct() : mixed
- Constructs a new instance of the class.
- __destruct() : void
- Destructs the object and cleans up resources.
- all() : array<string|int, mixed>|bool
- Retrieves all pages from the database.
- delete() : bool
- Deletes a record from the 'pages' table based on the given value and column.
- get() : array<string|int, mixed>|bool
- Retrieves a specific page from the database based on a given value and column.
- getall() : array<string|int, mixed>|bool
- Retrieves all pages from the database based on a specific value and column.
- insert() : bool
- Inserts a new page into the database.
- update() : bool
- Updates a record in the 'pages' table with the given column, value, and page ID.
Properties
$allowedCols
protected
array<string|int, mixed>
$allowedCols
= ['id', 'module', 'name', 'path', 'file', 'url', 'is_admin']
An array of allowed column names.
$db
Database connection object.
protected
db_master
$db
Methods
__construct()
Constructs a new instance of the class.
public
__construct() : mixed
Sets the database connection object based on the globally-available $dbm variable.
__destruct()
Destructs the object and cleans up resources.
public
__destruct() : void
This method is automatically called when the object is no longer referenced or destroyed. It unsets the 'db' and 'allowedCols' properties, freeing up memory and resources.
all()
Retrieves all pages from the database.
public
all([string $sort = 'module' ][, string $filter = '' ]) : array<string|int, mixed>|bool
Parameters
- $sort : string = 'module'
-
The column to sort the pages by. Default is 'module'.
- $filter : string = ''
Return values
array<string|int, mixed>|bool —An array of page data if pages exist, false otherwise.
delete()
Deletes a record from the 'pages' table based on the given value and column.
public
delete(string $val[, string $col = 'id' ]) : bool
If the column is not allowed, it will default to 'id'.
Parameters
- $val : string
-
The value to search for in the column.
- $col : string = 'id'
-
The column to search in. Default is 'id'.
Return values
bool —Returns true if the record is successfully deleted, false otherwise.
get()
Retrieves a specific page from the database based on a given value and column.
public
get(string $val[, string $col = 'url' ]) : array<string|int, mixed>|bool
Parameters
- $val : string
-
The value to search for in the specified column.
- $col : string = 'url'
-
The column to search for the specified value. Default is 'url'.
Return values
array<string|int, mixed>|bool —An array containing the page data if the page exists, false otherwise.
getall()
Retrieves all pages from the database based on a specific value and column.
public
getall(string $val[, string $col = 'url' ]) : array<string|int, mixed>|bool
Parameters
- $val : string
-
The value to match against the specified column.
- $col : string = 'url'
-
The column to compare the value against. Default is 'url'.
Return values
array<string|int, mixed>|bool —An array of page data if pages exist with the specified value and column, false otherwise.
insert()
Inserts a new page into the database.
public
insert(string $mod, string $name, string $path, string $file, string $url[, string $isadmin = '0' ]) : bool
Parameters
- $mod : string
-
The module of the page.
- $name : string
-
The name of the page.
- $path : string
-
The path of the page.
- $file : string
-
The file of the page.
- $url : string
-
The URL of the page.
- $isadmin : string = '0'
-
The admin status of the page. Default is '0'.
Return values
bool —Returns true if the page is inserted successfully, false otherwise.
update()
Updates a record in the 'pages' table with the given column, value, and page ID.
public
update(string $col, string $val, string $pid) : bool
If the column is not allowed, it will default to 'url'.
Parameters
- $col : string
-
The column to update.
- $val : string
-
The new value for the column.
- $pid : string
-
The page ID of the record to update.
Return values
bool —Returns true if the record is successfully updated, false otherwise.