Documentation

tab_customers

Represents a table of customers in a database.

This class provides methods to interact with the customer records in the database table.

Table of Contents

Properties

$allowedCols  : array<string|int, mixed>
$db  : db_tenant

Methods

__construct()  : void
Constructor for the class.
__destruct()  : mixed
Destructor method for cleaning up resources before the object is destroyed.
all()  : array<string|int, mixed>|bool
Retrieves all customers from the database based on the specified type, sort, and order.
all_tickets()  : array<string|int, mixed>|bool
delete()  : bool
Deletes a record from the 'customers' table based on the specified column and value.
get()  : array<string|int, mixed>|bool
Retrieves a customer record from the database based on the specified value and column.
insert()  : string|bool
Inserts a new record into the `customers` table.
search()  : array<string|int, mixed>|bool
Searches for customers based on a search term.
update()  : bool
Updates a record in the 'customers' table based on the specified column, value, and customer ID.

Properties

$allowedCols

protected array<string|int, mixed> $allowedCols = ['id', 'type', 'number', 'name', 'wk', 'mail', 'remail']

An array containing the names of allowed columns in a database table.

Methods

__construct()

Constructor for the class.

public __construct() : void

Initializes the class and sets the database connection.

__destruct()

Destructor method for cleaning up resources before the object is destroyed.

public __destruct() : mixed

Removes references to the database connection and allowed columns array.

all()

Retrieves all customers from the database based on the specified type, sort, and order.

public all([string $type = '-1' ][, string $sort = 'number' ][, string $order = 'ASC' ]) : array<string|int, mixed>|bool
Parameters
$type : string = '-1'

(Optional) The type of customers to retrieve. Defaults to '-1' to retrieve all customers.

$sort : string = 'number'

(Optional) The column to sort the customers by. Defaults to 'number'.

$order : string = 'ASC'

(Optional) The sort order. Defaults to 'ASC'.

Return values
array<string|int, mixed>|bool

An array of customer records if there are any, otherwise false.

all_tickets()

public all_tickets([string $uid = '' ][, string $status = '' ]) : array<string|int, mixed>|bool
Parameters
$uid : string = ''
$status : string = ''
Return values
array<string|int, mixed>|bool

delete()

Deletes a record from the 'customers' table based on the specified column and value.

public delete(string $val[, string $col = 'id' ]) : bool
Parameters
$val : string

The value to match in the specified column.

$col : string = 'id'

The column to search for the specified value. Defaults to 'id'.

Return values
bool

Returns true if the record was deleted successfully, false otherwise.

get()

Retrieves a customer record from the database based on the specified value and column.

public get(string $val[, string $col = 'id' ]) : array<string|int, mixed>|bool
Parameters
$val : string

The value to search for.

$col : string = 'id'

(Optional) The column to search in. Defaults to 'id'.

Return values
array<string|int, mixed>|bool

The customer record if found, otherwise false.

insert()

Inserts a new record into the `customers` table.

public insert(string $type, string $number, string $name, string $email[, string $remail = '' ][, string $wk = '0' ]) : string|bool
Parameters
$type : string

The type of customer.

$number : string

The customer number.

$name : string

The name of the customer.

$email : string

The email address of the customer.

$remail : string = ''

The invoice email address of the customer. Default is an empty string.

$wk : string = '0'

The work status of the customer. Default is '0'.

Return values
string|bool

The ID of the inserted record if successful, otherwise returns false.

Searches for customers based on a search term.

public search(string $term) : array<string|int, mixed>|bool
Parameters
$term : string

The search term to look for in the customer's name or number.

Return values
array<string|int, mixed>|bool

Returns an array of customers if found, otherwise returns false.

update()

Updates a record in the 'customers' table based on the specified column, value, and customer ID.

public update(string $col, string $val, string $cid) : bool
Parameters
$col : string

The column to update in the record.

$val : string

The value to set in the specified column.

$cid : string

The ID of the customer record to update.

Return values
bool

Returns true if the record was updated successfully, false otherwise.


        
On this page

Search results