ActiveRecordTrait uses trait:short
Gives an object the ability to act as a proxy for a record in the database.
In order for properties to act as proxies for columns in the database they must be protected properties that match their corresponding columns in the database. Furthermore, the properties $operating_table and $schema must exist on the class implementing this Trait
Tags
Table of Contents
Properties
- $error_message : string
- $id : int
- $operating_table : string
- $schema : string
- $allowed_props : array<string|int, mixed>
- $prop_types : array<string|int, mixed>
- $unsaved_props : array<string|int, mixed>
Methods
- __set() : void
- Set a property for this node, the value will not be saved until the 'save' method is called.
- configErrorMessage() : string
- Returns the configuration error message.
- generateRelativeName() : string
- Gets the `generate_relative_name_from_display_name`.
- getAllowedProps() : array<string|int, mixed>
- Get the allowed properties for this Node Return an array intersection of the Class Properties and Table Columns.
- getConfig() : TiqConfig
- Gets the TIQ configuration.
- getDb() : PgSQL
- Gets database instance.
- isDebug() : bool
- Is debug mode or not.
- JSONSerializeRecord() : array<string|int, mixed>
- Returns an array that can can easily be json_encoded
- save() : void
- writes updated properties into the database, or creates it if it does not exist.
- setProps() : void
- Loads all database columns as static variables. To load a variable, it must exist in the class.
Properties
$error_message
public
static string
$error_message
= 'An issue occurred, please contact ThinkIQ for Support and enable debugging'
- Base error message
$id
public
int
$id
$operating_table
public
string
$operating_table
$schema
public
string
$schema
$allowed_props
protected
array<string|int, mixed>
$allowed_props
= []
$prop_types
protected
array<string|int, mixed>
$prop_types
= []
$unsaved_props
protected
array<string|int, mixed>
$unsaved_props
= []
Methods
__set()
Set a property for this node, the value will not be saved until the 'save' method is called.
public
__set(string $prop, mixed $value) : void
Parameters
- $prop : string
-
- The property we want to set.
- $value : mixed
-
- The value we want to set into the property.
configErrorMessage()
Returns the configuration error message.
public
static configErrorMessage() : string
Return values
stringgenerateRelativeName()
Gets the `generate_relative_name_from_display_name`.
public
static generateRelativeName(string $displayName[, string|null $typeName = null ][, int|null $partOfId = null ][, int|null $nodeId = null ]) : string
Parameters
- $displayName : string
-
- The display name we are searching.
- $typeName : string|null = null
-
- The type name we are searching.
- $partOfId : int|null = null
-
- The part of ID we are searching.
- $nodeId : int|null = null
-
- The Node ID that we are searching.
Return values
stringgetAllowedProps()
Get the allowed properties for this Node Return an array intersection of the Class Properties and Table Columns.
public
getAllowedProps() : array<string|int, mixed>
Return values
array<string|int, mixed>getConfig()
Gets the TIQ configuration.
public
static getConfig() : TiqConfig
Return values
TiqConfiggetDb()
Gets database instance.
public
static getDb() : PgSQL
The database connection is stored in a static property within the DatabaseConnectionManager class, ensuring that it is truly a singleton across the entire application, regardless of which class calls this method.
Return values
PgSQLisDebug()
Is debug mode or not.
public
static isDebug() : bool
Return values
boolJSONSerializeRecord()
Returns an array that can can easily be json_encoded
public
JSONSerializeRecord() : array<string|int, mixed>
Return values
array<string|int, mixed>save()
writes updated properties into the database, or creates it if it does not exist.
public
save() : void
Tags
setProps()
Loads all database columns as static variables. To load a variable, it must exist in the class.
protected
setProps([array<string|int, mixed> $config = [] ][, array<string|int, mixed> $additionalMethods = [] ]) : void
If the 'id' property is not set, we still run this function, populating the $allowed_props variable.
Parameters
- $config : array<string|int, mixed> = []
-
- This array contains the same properties as a record from the corresponding table in the database.
- $additionalMethods : array<string|int, mixed> = []
-
- Methods to be call to call when we initiate the class.