Documentation

main

Class Main

This class represents the main functionality for articles management.

Table of Contents

Properties

$tarticles  : tab_articles

Methods

__construct()  : void
Constructs a new instance of the class.
__destruct()  : void
Destroys the object and frees up resources.
all()  : array<string|int, mixed>|bool
Retrieves all articles.
delete()  : bool
Deletes records that match the given value in the specified column.
get()  : array<string|int, mixed>|bool
Retrieves an article by a given value in a specified column.
getall()  : array<string|int, mixed>|bool
Retrieves all articles based on a specific value and column.
insert()  : bool|int
Inserts an article into the database.
search()  : array<string|int, mixed>|bool
Searches for articles that match the given term.
update()  : bool
Updates records that match the given ID with the specified column and value.

Properties

$tarticles

protected tab_articles $tarticles

Contains the database actions of articles

Methods

__construct()

Constructs a new instance of the class.

public __construct() : void

__destruct()

Destroys the object and frees up resources.

public __destruct() : void

all()

Retrieves all articles.

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

The field to sort the articles by. Default is 'number'.

$order : string = 'ASC'

The order in which the articles should be sorted. Default is 'ASC'.

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

Returns an array of articles if successful, false otherwise.

delete()

Deletes records that match the given value in the specified column.

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

The value to match.

$col : string = 'id'

(optional) The column to search for the value. Default is 'id'.

Return values
bool

Returns true if the deletion is successful, false otherwise.

get()

Retrieves an article by a given value in a specified column.

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

The value to search for.

$col : string = 'number'

The column in which to search for the value. Default is 'number'.

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

Returns an array containing the found article if successful, false otherwise.

getall()

Retrieves all articles based on a specific value and column.

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 in. Default is 'number'.

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

Returns an array of articles if successful, false otherwise.

insert()

Inserts an article into the database.

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 article number.

$name : string

The article name.

$price : string

The article price.

$unit : string

The article unit.

$desc : string = ''

The article description (optional).

$warehouse : string = '0'

The article warehouse (optional, default value is '0').

$stock : string = '0'

The article stock (optional, default value is '0').

$inactive : string = '0'

The article inactive status (optional, default value is '0').

Return values
bool|int

Returns true if the insertion was successful, or the inserted article ID (integer) if the database supports auto-incrementing primary keys.

Searches for articles that match the given term.

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

The term to search for.

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

Returns an array of articles that match the term if found, or false if no matching articles are found.

update()

Updates records that match the given ID with the specified column and value.

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

The column to update.

$val : string

The value to set for the column.

$id : string

The ID of the record to update.

Return values
bool

Returns true if the update is successful, false otherwise.


        
On this page

Search results