Documentation

Reference
in package

The Reference class provides methods for managing and retrieving reference data from a MySQL database.

It includes operations for fetching, creating, and updating references. This class is optimized for scenarios that require both user-level and admin-level data interaction.

Table of Contents

Properties

$mySql  : MySql

Methods

__construct()  : mixed
createByAdmin()  : void
Create a new reference (admin).
getAll()  : array<int, array<string, mixed>>
Get all references filtered by status.
getByCode()  : array<string, mixed>
Get a single reference by its code.
updateByCode()  : void
Update a reference by code (admin).

Properties

Methods

createByAdmin()

Create a new reference (admin).

public createByAdmin(array<string, mixed> $data) : void

Expects in $data:

  • reference_code (string, required)
  • reference_name (string, required)
  • reference_type_code (string|null, optional)
  • sort_order (int|null)
  • status (int, required)
  • createdby (string, required)
  • modifiedby (string, required)

Behaviour for reference_type_code:

  • empty or not provided → reference_type_id = NULL, reference_type_code = NULL
  • provided but unknown → reference_type_id = NULL, reference_type_code kept as given
Parameters
$data : array<string, mixed>

getAll()

Get all references filtered by status.

public getAll(array<string|int, int> $statuses) : array<int, array<string, mixed>>
Parameters
$statuses : array<string|int, int>
Return values
array<int, array<string, mixed>>

getByCode()

Get a single reference by its code.

public getByCode(string $code) : array<string, mixed>
Parameters
$code : string
Return values
array<string, mixed>

updateByCode()

Update a reference by code (admin).

public updateByCode(array<string, mixed> $data) : void

Expects in $data:

  • reference_code (string, required)
  • reference_name (string|null)
  • reference_type_code (string|null, presence matters)
  • sort_order (int|null)
  • status (int|null)
  • modifiedby (string, required)

Behaviour for reference_type_code:

  • key not present → keep existing id+code
  • present but empty → set type_id = NULL, type_code = NULL
  • present & non-empty → try resolve id (NULL if unknown), update both
Parameters
$data : array<string, mixed>

        
On this page

Search results