tab_tickets_articles
in package
Class tab_tickets_articles
This class represents a table of tickets articles and provides methods for retrieving, inserting, updating, and deleting records in the table.
Table of Contents
Properties
- $allowedCols : array<string|int, mixed>
- $db : db_tenant
Methods
- __construct() : mixed
- Constructor function for the class.
- __destruct() : void
- The __destruct method for the class.
- delete() : bool
- Deletes a record from the database based on the given value and column.
- get() : array<string|int, mixed>|bool
- Retrieves the first record from the `tickets_articles` table that matches the specified value in the specified column.
- getall() : array<string|int, mixed>|bool
- Retrieves all the records from the `tickets_articles` table that match the specified value in the specified column.
- insert() : bool
- Inserts a new record into the `tickets_articles` table.
- update() : bool
- Updates a record in the database based on the given column, value, and id.
Properties
$allowedCols
protected
array<string|int, mixed>
$allowedCols
= ['id', 'tnumber', 'tmid', 'created', 'type', 'aid', 'amount', 'serial']
An array containing the allowed column names. Each element represents a column name in the database table. This array is used for validation and filtering purposes.
$db
protected
db_tenant
$db
An instance of the DatabaseConnection class.
Methods
__construct()
Constructor function for the class.
public
__construct() : mixed
Initializes the $db property with the global $dbt object.
__destruct()
The __destruct method for the class.
public
__destruct() : void
This method is automatically called when the object is destroyed. It is responsible for cleaning up any resources used by the object.
delete()
Deletes a record from the database based on the given value and column.
public
delete(string $val[, string $col = 'tmid' ]) : bool
Parameters
- $val : string
-
The value to search for in the specified column.
- $col : string = 'tmid'
-
The column to search for the value in. Default is 'tmid'.
Return values
bool —Returns true if the record is successfully deleted, otherwise false.
get()
Retrieves the first record from the `tickets_articles` table that matches the specified value in the specified column.
public
get(string $val[, string $col = 'tmid' ]) : array<string|int, mixed>|bool
Parameters
- $val : string
-
The value to search for in the specified column.
- $col : string = 'tmid'
-
The column name to search for the specified value. Defaults to 'tmid'.
Return values
array<string|int, mixed>|bool —Returns an array representing the first record if found, otherwise returns false.
getall()
Retrieves all the records from the `tickets_articles` table that match the specified value in the specified column.
public
getall(string $val[, string $col = 'tmid' ]) : array<string|int, mixed>|bool
Parameters
- $val : string
-
The value to search for in the specified column.
- $col : string = 'tmid'
-
The column name to search for the specified value. Defaults to 'tmid'.
Return values
array<string|int, mixed>|bool —Returns an array of records if found, otherwise returns false.
insert()
Inserts a new record into the `tickets_articles` table.
public
insert(string $tnumber, string $tmid, string $aid, string $amount[, string $type = '0' ][, string $serial = '' ]) : bool
Parameters
- $tnumber : string
-
The tnumber value.
- $tmid : string
-
The tmid value.
- $aid : string
-
The aid value.
- $amount : string
-
The amount value.
- $type : string = '0'
-
The type value (optional, default is '0' (geliefert), '1' (abgeholt).
- $serial : string = ''
-
The serial value (optional, default is '').
Return values
bool —Returns true on successful insertion, false otherwise.
update()
Updates a record in the database based on the given column, value, and id.
public
update(string $col, string $val, string $id) : bool
Parameters
- $col : string
-
The column to update.
- $val : string
-
The new value.
- $id : string
-
The id of the record to update.
Return values
bool —Returns true if the record is successfully updated, otherwise false.