Documentation

tab_articles

Class tab_articles

Represents a table containing articles.

Table of Contents

Properties

$allowedCols  : array<string|int, mixed>
An array containing the names of allowed columns.
$db  : db_tenant
Database connection object.

Methods

__construct()  : void
Constructs a new instance of the class.
__destruct()  : mixed
Destructs the class instance and performs necessary cleanup tasks.
all()  : array<string|int, mixed>|bool
Retrieves all articles from the database.
delete()  : bool
Deletes a record from the "articles" table based on the specified column and value.
get()  : array<string|int, mixed>|bool
Retrieves a specific article from the database based on a given value and column.
getall()  : array<string|int, mixed>|bool
Retrieves articles from the database based on a specific column value.
insert()  : bool|int
Insert a new record into the "articles" table.
search()  : array<string|int, mixed>|bool
Searches the articles table for records matching the given term.
update()  : bool
Updates a record in the "articles" table with the specified column and value based on the given ID.

Properties

$allowedCols

An array containing the names of allowed columns.

protected array<string|int, mixed> $allowedCols = ['id', 'number', 'name', 'price', 'unit', 'desc', 'warehouse', 'stock', 'inactive']
Tags
example

['id','number','name','price','unit','desc','warehouse','stock','inactive']

Methods

__construct()

Constructs a new instance of the class.

public __construct() : void

Initializes the database connection for the class.

__destruct()

Destructs the class instance and performs necessary cleanup tasks.

public __destruct() : mixed

This method is automatically called when the object is no longer referenced. It removes the references to the database connection object and the allowed columns array.

all()

Retrieves all articles from the database.

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

The column to sort the results by. Defaults to 'number'.

$order : string = 'ASC'

The order to sort the results in. Defaults to 'ASC'.

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

Returns an array of articles if successful, otherwise returns false.

delete()

Deletes a record from the "articles" table based on the specified column and value.

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

The value to search for in the specified column.

$col : string = 'id'

[optional] The column to search in. Defaults to 'id' if not specified.

Return values
bool

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

get()

Retrieves a specific article from the database based on a given value and column.

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

The value to search for in the specified column.

$col : string = 'number'

The column to search for the value in. Defaults to 'number'.

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

Returns an array with the article if found, otherwise returns false.

getall()

Retrieves articles from the database based on a specific column value.

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

The value to search for in the specified column.

$col : string = 'number'

The column to search for the given value. Defaults to 'number'.

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

Returns an array of articles if successful, otherwise returns false.

insert()

Insert a new record into the "articles" table.

public insert(string $number, string $name, string $price, string $unit[, string $desc = '' ][, string $warehouse = '0' ][, string $stock = '0' ][, string $inactive = '0' ]) : bool|int
Parameters
$number : string

The number of the article.

$name : string

The name of the article.

$price : string

The price of the article.

$unit : string

The unit of measurement for the article.

$desc : string = ''

The description of the article. (optional)

$warehouse : string = '0'

The warehouse of the article. (optional)

$stock : string = '0'

The stock of the article. (optional)

$inactive : string = '0'

The inactive status of the article. (optional)

Return values
bool|int

If the insertion was successful, returns the last inserted ID. Otherwise, returns false.

Searches the articles table for records matching the given term.

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

The term to search for in the articles table.

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

Returns an array of matching records if found, otherwise false.

update()

Updates a record in the "articles" table with the specified column and value based on the given ID.

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

The column to update.

$val : string

The new value for the specified column.

$id : string

The ID of the record to update.

Return values
bool

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


        
On this page

Search results