tab_tickets_messages
in package
Represents a class for interacting with the `tickets_messages` table in the database.
Table of Contents
Properties
- $allowedCols : array<string|int, mixed>
- $db : db_tenant
- Database connection object.
Methods
- __construct() : void
- Constructor for the class.
- __destruct() : mixed
- Destructor for the class when an object is destroyed.
- delete() : bool
- Deletes a record from the `tickets_messages` table based on the specified column and value.
- get() : array<string|int, mixed>|bool
- Retrieves a record from the `tickets_messages` table based on a given value.
- getall() : array<string|int, mixed>|bool
- Retrieves all records from the `tickets_messages` table that match the specified column and value.
- insert() : string|int|bool
- Inserts a new record into the "tickets_messages" table.
- update() : bool
- Updates a record in the `tickets_messages` table based on the specified column, value, and tmid.
Properties
$allowedCols
protected
array<string|int, mixed>
$allowedCols
= ['id', 'tid', 'tnumber', 'type', 'created', 'uid', 'name', 'email', 'message']
The allowed columns in the database table.
$db
Database connection object.
protected
db_tenant
$db
Methods
__construct()
Constructor for the class.
public
__construct() : void
Assigns the global database object to the local variable $this->db.
__destruct()
Destructor for the class when an object is destroyed.
public
__destruct() : mixed
It unsets the database connection and the allowed columns property.
delete()
Deletes a record from the `tickets_messages` table based on the specified column and value.
public
delete(string $val[, string $col = 'tid' ]) : bool
Parameters
- $val : string
-
The value to match against the specified column.
- $col : string = 'tid'
-
The column to use for matching. Defaults to 'tid'.
Return values
bool —Returns true if the record was successfully deleted, false otherwise.
get()
Retrieves a record from the `tickets_messages` table based on a given value.
public
get(string $val[, string $col = 'tnumber' ]) : array<string|int, mixed>|bool
Parameters
- $val : string
-
The value to search for in the specified column.
- $col : string = 'tnumber'
-
(optional) The column to search in. Default is 'tnumber'.
Return values
array<string|int, mixed>|bool —Returns an array containing the record if found, or false if an error occurs or no record found.
getall()
Retrieves all records from the `tickets_messages` table that match the specified column and value.
public
getall(string $col, string $val[, string $sort = 'created' ][, string $order = 'DESC' ]) : array<string|int, mixed>|bool
Parameters
- $col : string
-
The column to search for. Must be one of the allowed columns.
- $val : string
-
The value to search for.
- $sort : string = 'created'
-
(optional) The column to sort the records by. Default is 'created'.
- $order : string = 'DESC'
-
(optional) The order of the sorted records. Default is 'DESC'.
Return values
array<string|int, mixed>|bool —Returns an array containing all the records that match the column and value if successful, or false if an error occurs or no records found.
insert()
Inserts a new record into the "tickets_messages" table.
public
insert(string $tid, string $tnumber, string $typeid, string $uid, string $email, string $message[, string $uname = '' ]) : string|int|bool
Parameters
- $tid : string
-
The ticket ID.
- $tnumber : string
-
The ticket number.
- $typeid : string
-
The type ID.
- $uid : string
-
The user ID.
- $email : string
-
The user email.
- $message : string
-
The message content.
- $uname : string = ''
-
The user name (optional).
Return values
string|int|bool —Returns the last inserted ID as a string or integer if the insertion is successful. Returns false otherwise.
update()
Updates a record in the `tickets_messages` table based on the specified column, value, and tmid.
public
update(string $col, string $val, string $tmid) : bool
Parameters
- $col : string
-
The column to update.
- $val : string
-
The new value for the specified column.
- $tmid : string
-
The tmid (id) of the record to update.
Return values
bool —Returns true if the record was successfully updated, false otherwise.