KpiSafety
in package
Class KpiSafety
This class provides functionality to manage KPI safety records, including retrieving, creating, and updating records. It interacts with the database to perform operations specific to KPI safety data.
Table of Contents
Properties
Methods
- __construct() : mixed
- createByAdmin() : void
- Create KPI safety (admin).
- getAll() : array<int, array<string, mixed>>
- Get all KPI safety records by status.
- getByCode() : array<string, mixed>
- Get KPI safety record by code.
- updateByCode() : void
- Update KPI safety by code (admin).
Properties
$mySql
protected
MySql
$mySql
Methods
__construct()
public
__construct(MySql $mySql) : mixed
Parameters
- $mySql : MySql
createByAdmin()
Create KPI safety (admin).
public
createByAdmin(array<string, mixed> $data) : void
Expects in $data:
- kpi_safety_code (string, required)
- kpi_safety_name (string, required)
- kpi_safety_name_search (string|null)
- reference_code (string|null)
- datapoint_code (string|null)
- kpi_category_code (string|null)
- sort_order (int|null)
- status (int, required)
- createdby (string, required)
- modifiedby (string, required)
Parameters
- $data : array<string, mixed>
getAll()
Get all KPI safety records 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 KPI safety record by code.
public
getByCode(string $code) : array<string, mixed>
Parameters
- $code : string
Return values
array<string, mixed>updateByCode()
Update KPI safety by code (admin).
public
updateByCode(array<string, mixed> $data) : void
Behaviour for FKs:
- If *_code key is not present in $data → keep existing id+code.
- If present but empty string → set id+code to NULL.
- If present with non-empty value → resolve id by code and update both.
Expects in $data:
- kpi_safety_code (string, required)
- kpi_safety_name (string|null)
- kpi_safety_name_search (string|null)
- reference_code (string|null, presence matters)
- datapoint_code (string|null, presence matters)
- kpi_category_code (string|null, presence matters)
- sort_order (int|null)
- status (int|null)
- modifiedby (string, required)
Parameters
- $data : array<string, mixed>