tab_search
in package
Represents a class for searching in tenants database.
Table of Contents
Properties
- $allowedCols : array<string|int, mixed>
- $db : db_master
- Represents the database connection.
Methods
- __construct() : void
- Initializes a new instance of the class.
- __destruct() : mixed
- Destructor method that is automatically called when an object is no longer referenced or when the script finishes executing.
- all() : array<string|int, mixed>|bool
- Retrieves all records from the `search` table from the database, ordered by the given column and in the given order.
- delete() : bool
- Deletes a record from the `search` table in the database based on the given value and column.
- get() : array<string|int, mixed>|bool
- Retrieves a record from the `search` table based on the given value and column.
- insert() : bool
- Inserts a new record into the `search` table in the database.
- update() : bool
- Updates the 'active' field of a record in the `search` table for a given tenant.
Properties
$allowedCols
protected
array<string|int, mixed>
$allowedCols
= ['id', 'tenant', 'active']
Array containing the column names that are allowed
$db
Represents the database connection.
protected
db_master
$db
The db_master object used to interact with the database.
Methods
__construct()
Initializes a new instance of the class.
public
__construct() : void
__destruct()
Destructor method that is automatically called when an object is no longer referenced or when the script finishes executing.
public
__destruct() : mixed
It unset the reference to the $db
and $allowedCols
properties, freeing up memory.
all()
Retrieves all records from the `search` table from the database, ordered by the given column and in the given order.
public
all([string $sort = 'id' ][, string $order = 'ASC' ]) : array<string|int, mixed>|bool
Parameters
- $sort : string = 'id'
-
The column name to sort the results by. Default is 'id'.
- $order : string = 'ASC'
-
The order in which the results should be returned. Default is 'ASC'.
Return values
array<string|int, mixed>|bool —Returns an array of records from the search
table ordered by the specified column and order.
Returns false if no records are found.
delete()
Deletes a record from the `search` table in the database 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 name to search for the specified value. Default is 'id'.
Return values
bool —Returns true if a record is successfully deleted. Otherwise, returns false.
get()
Retrieves a record from the `search` table based on the given value and column.
public
get(string $val[, string $col = 'tenant' ]) : array<string|int, mixed>|bool
Parameters
- $val : string
-
The value to search for.
- $col : string = 'tenant'
-
(optional) The column to search in. Defaults to 'tenant' if not provided.
Return values
array<string|int, mixed>|bool —Returns the first matching record as an array. If no matching record is found, returns false.
insert()
Inserts a new record into the `search` table in the database.
public
insert(string $tenant, string $active) : bool
Parameters
- $tenant : string
-
The tenant name to be inserted.
- $active : string
-
The active status to be inserted.
Return values
bool —Returns true if the record was successfully inserted, false otherwise.
update()
Updates the 'active' field of a record in the `search` table for a given tenant.
public
update(string $tenant, string $active) : bool
Parameters
- $tenant : string
-
The tenant value for the record to be updated.
- $active : string
-
The new value for the 'active' field.
Return values
bool —Returns true if the update was successful, false otherwise.