Sequence
extends ActiveRecord
in package
implements
TypeInterface
A custom sequence datatype, which is stored as a string and is made up of a string prefix and an integer sequence, which is stored in a database.
Tags
Table of Contents
Interfaces
- TypeInterface
- The interface for all complex data types.
Constants
- MAX_SIZE = 255
- The absolute maximum size of the value for the this Sequence.
- TABLE_NAME = 'Sequence'
- The name of the database table for the class.
Properties
- $created_by : Integer
- The ID of the person who created this record.
- $created_ts : Timestamp
- The timestamp of creation.
- $dataLabels : array<string|int, mixed>
- An array of data display labels for the class properties.
- $defaultAttributes : array<string|int, mixed>
- An array of the names of all of the default attributes of a persistent Record defined in this class.
- $helper : string
- The message to display to the user when validation fails.
- $ID : int
- The object ID.
- $lastQuery : string
- The last database query run by this object. Useful for tracing an error.
- $prefix : String
- The string prefix (must be capital alphabet characters only).
- $sequence : Integer
- The integer sequence number incremented for each Sequence value with this prefix.
- $size : int
- The size of the value for the this Sequence.
- $transientAttributes : array<string|int, mixed>
- An array of the names of all of the transient attributes of a persistent Record which are not saved to the DB.
- $uniqueAttributes : array<string|int, mixed>
- An array of the uniquely-constained attributes of this persistent record.
- $updated_by : Integer
- The ID of the person who last updated this record.
- $updated_ts : Timestamp
- The timestamp of the last update.
- $validationRule : string
- The validation rule for the Sequence type.
- $version_num : Integer
- The version number of the object, used for locking mechanism.
- $logger : Logger
- Trace logger.
- $maintainHistory : bool
- Determines if we will maintain a _history table for this record (default is false).
Methods
- __construct() : mixed
- The constructor.
- __toString() : string
- Used to convert the object to a printable string.
- __wakeup() : void
- Re-initialize the static logger property on the Record after de-serialize, as PHP does not serialize static properties.
- addProperty() : void
- Adds in a new class property without loosing existing data (does an ALTER TABLE query on the database).
- addToCache() : void
- Stores the business object to the configured cache instance.
- backupDatabase() : void
- Backup the configured database.
- begin() : void
- Starts a new database transaction.
- cast() : ActiveRecord
- Cast a Record to another type of record. A new Record will be returned with the same ID and version_num as the old record, so this is NOT a true cast but is a copy. All attribute values will be copied accross.
- checkDatabaseExists() : bool
- Check to see if the configured database exists.
- checkRecordExists() : bool
- Checks that a record exists for the Record in the database.
- checkRecordTableExists() : bool
- Static method to check the database and see if the table for the indicated Record class name exists (assumes table name will be $recordClassName less "Object").
- checkTableExists() : bool
- Checks to see if the table exists in the database for the current business class.
- checkTableNeedsUpdate() : bool
- Checks to see if the table in the database matches (for fields) the business class definition, i.e. if the database table is in sync with the class definition.
- commit() : void
- Commits the current database transaction.
- createDatabase() : void
- Creates the configured database.
- createForeignIndex() : void
- Creates a foreign key constraint (index) in the database on the given attribute.
- createUniqueIndex() : void
- Creates a unique index in the database on the given attribute(s).
- delete() : void
- Deletes the current object from the database.
- deleteAllByAttribute() : int
- Delete all object instances from the database by the specified attribute matching the value provided. Returns the count of deleted records.
- disconnect() : void
- Disconnects the current database connection if one exists.
- dropDatabase() : void
- Drops the configured database.
- dropTable() : void
- Drops the table if the model requirements have changed. All data is lost!
- findMissingFields() : array<string|int, mixed>
- Returns an array containing any properties on the class which have not been created on the database table yet.
- get() : mixed
- Generic getter method for accessing class properties. Will use the method get.ucfirst($prop) instead if that method exists at a child level (by default). Set $noChildMethods to true if you don't want to use any get.ucfirst($prop) method even if it exists, false otherwise (default).
- getCount() : int
- Gets the count from the database for the amount of objects of this class.
- getCreateTS() : Timestamp
- Method for getting the date/time of when the Record was created.
- getCreatorId() : Integer
- Method for getting the ID of the person who created this record.
- getDataLabel() : string
- Gets the data label for the given attribute name.
- getDataLabels() : array<string|int, mixed>
- Gets the data labels array.
- getDefaultAttributes() : array<string|int, mixed>
- Get the array of default attribute names.
- getFriendlyClassName() : string
- Returns the simple class name, stripped of the namespace.
- getHelper() : string
- Getter for the validation helper string.
- getHistoryCount() : int
- Gets the count from the database for the amount of entries in the [tableName]_history table for this business object. Only call this method on classes where maintainHistory = true, otherwise an exception will be thrown.
- getID() : string
- Gets the ID for the object in 11 digit zero-padded format (same as getID()).
- getIndexes() : array<string|int, mixed>
- Gets an array of all of the names of the active database indexes for this class.
- getLastQuery() : string
- Get the last database query run on this object.
- getMaintainHistory() : bool
- Gets the value of the maintainHistory attribute.
- getMAX() : int
- Gets the maximum ID value from the database for this class type.
- getPersistentAttributes() : array<string|int, mixed>
- Get the array of persistent attribute names, i.e. those that are saved in the database.
- getPropObject() : mixed
- Gets the property object rather than the value for complex attributes. Returns false if the property exists but is private.
- getRecordClassNames() : array<string|int, mixed>
- Loops over the core and custom Record directories and builds an array of all of the Record class names in the system.
- getRule() : string
- Get the validation rule.
- getSize() : int
- Get the allowable size of the Sequence in the database field.
- getTableName() : string
- Getter for the TABLE_NAME, the name of the table in the database for this class, which should be set by a child of this class.
- getTaggedAttributes() : array<string|int, mixed>
- Returns the contents of the taggedAttributes array, or an empty array if that does not exist.
- getTransientAttributes() : array<string|int, mixed>
- Get the array of transient attribute names.
- getUniqueAttributes() : array<string|int, mixed>
- Returns the array of names of unique attributes on this record.
- getUpdateTS() : Timestamp
- Method for getting the date/time of when the Record was last updated.
- getUpdatorId() : Integer
- Method for getting the ID of the person who updated this record.
- getValue() : string
- Used to get the Sequence value as a string.
- getVersion() : int
- Gets the version_num of the object from the database (returns 0 if the Record is not saved yet).
- getVersionNumber() : Integer
- Method for getting version number of the object.
- hasAttribute() : bool
- Check to see if an attribute exists on the record.
- isInstalled() : bool
- Static method that tries to determine if the system database has been installed or not.
- isTableOverloaded() : bool
- Checks to see if the table name matches the classname, and if not if the table name matches the classname name of another record, i.e. the table is used to store multiple types of records.
- isTagged() : bool
- Returns true if the Record has a Relation property called tags, false otherwise.
- isTransient() : bool
- Inspector to see if the business object is transient (not presently stored in the database).
- load() : void
- Populates the child object with the properties retrived from the database for the object $ID.
- loadAll() : array<string|int, mixed>
- Loads all of the objects of this class into an array which is returned.
- loadAllByAttribute() : array<string|int, mixed>
- Loads all of the objects of this class by the specified attribute into an array which is returned.
- loadAllByAttributes() : array<string|int, mixed>
- Loads all of the objects of this class by the specified attributes into an array which is returned.
- loadAllByDayUpdated() : array<string|int, mixed>
- Loads all of the objects of this class that where updated (updated_ts value) on the date indicated.
- loadAllFieldValuesByAttribute() : array<string|int, mixed>
- Loads all of the specified attribute values of this class by the specified attribute into an array which is returned.
- loadAllOldVersions() : array<string|int, mixed>
- Load all old versions (if any) of this record from the [tablename]_history table.
- loadByAttribute() : void
- Populates the child object from the database table by the given attribute value.
- loadFromCache() : bool
- Attempts to load the business object from the configured cache instance, returns true on a cache hit.
- makeHistoryTable() : void
- Builds a new database table for the Record class to story it's history of changes.
- makeTable() : void
- Builds a new database table for the Record class.
- markPersistent() : void
- Removes the name of the attribute provided from the list of transient (non-saved) attributes for this record, ensuring that it will be saved on the next attempt.
- markTransient() : void
- Adds the name of the attribute provided to the list of transient (non-saved) attributes for this record.
- populateFromArray() : void
- Populates the current business object from the provided hash array.
- query() : array<string|int, mixed>
- Returns a 2d array, where each element in the array is another array representing a database row.
- rebuildTable() : void
- Re-builds the table if the model requirements have changed. All data is lost!
- reload() : void
- Reloads the object from the database, overwritting any attribute values in memory.
- removeFromCache() : void
- Removes the business object from the configured cache instance.
- rollback() : void
- Aborts the current database transaction.
- save() : void
- Saves the object. If $this->ID is empty or null it will INSERT, otherwise UPDATE.
- saveAttribute() : void
- Saves the field specified with the value supplied. Only works for persistent records. Note that no Alpha type validation is performed with this method!
- saveHistory() : void
- Saves the history of the object in the [tablename]_history table. It will always perform an insert.
- saveRelations() : void
- Saves relationship values, including lookup entries, for this record.
- set() : void
- Generic setter method for setting class properties. Will use the method set.ucfirst($prop) instead if that method exists at a child level (by default). Set $noChildMethods to true if you don't want to use any get.ucfirst($prop) method even if it exists, false otherwise (default).
- setDataLabels() : void
- Sets the data labels array.
- setHelper() : void
- Set the validation helper text.
- setID() : void
- Setter for the Object ID (ID).
- setLastQuery() : void
- Sets the last query executed on this business object.
- setMaintainHistory() : void
- Sets maintainHistory attribute on this DAO.
- setSequenceToNext() : void
- Sets the sequence number to be the maximum value matching the prefix in the database plus one. Note that calling this method increments the maximum value in the database.
- setValue() : void
- Accepts a string to set the Sequence prefix/sequence values to, in the format PREFIX-00000000000.
- toArray() : array<string|int, mixed>
- Return a hash array of the object containing attribute names and simplfied values.
- markUnique() : void
- Adds the name of the attribute(s) provided to the list of unique (constrained) attributes for this record.
- setEnumOptions() : void
- Populate all of the enum options for this object from the database.
- validate() : void
- Validates the object to be saved.
- clear() : void
- Unsets all of the attributes of this object to null.
- setVersion() : void
- Setter for the Record version number.
Constants
MAX_SIZE
The absolute maximum size of the value for the this Sequence.
public
int
MAX_SIZE
= 255
Tags
TABLE_NAME
The name of the database table for the class.
public
string
TABLE_NAME
= 'Sequence'
Tags
Properties
$created_by
The ID of the person who created this record.
protected
Integer
$created_by
Tags
$created_ts
The timestamp of creation.
protected
Timestamp
$created_ts
Tags
$dataLabels
An array of data display labels for the class properties.
protected
array<string|int, mixed>
$dataLabels
= array('ID' => 'Sequence ID#', 'prefix' => 'Sequence prefix', 'sequence' => 'Sequence number')
Tags
$defaultAttributes
An array of the names of all of the default attributes of a persistent Record defined in this class.
protected
array<string|int, mixed>
$defaultAttributes
= array('ID', 'lastQuery', 'version_num', 'dataLabels', 'created_ts', 'created_by', 'updated_ts', 'updated_by', 'defaultAttributes', 'transientAttributes', 'uniqueAttributes', 'TABLE_NAME', 'logger')
Tags
$helper
The message to display to the user when validation fails.
protected
string
$helper
= 'Not a valid sequence value!'
Tags
$ID
The object ID.
protected
int
$ID
Tags
$lastQuery
The last database query run by this object. Useful for tracing an error.
protected
string
$lastQuery
= ''
Tags
$prefix
The string prefix (must be capital alphabet characters only).
protected
String
$prefix
Tags
$sequence
The integer sequence number incremented for each Sequence value with this prefix.
protected
Integer
$sequence
Tags
$size
The size of the value for the this Sequence.
protected
int
$size
= 255
Tags
$transientAttributes
An array of the names of all of the transient attributes of a persistent Record which are not saved to the DB.
protected
array<string|int, mixed>
$transientAttributes
= array('lastQuery', 'dataLabels', 'defaultAttributes', 'transientAttributes', 'uniqueAttributes', 'TABLE_NAME', 'logger')
Tags
$uniqueAttributes
An array of the uniquely-constained attributes of this persistent record.
protected
array<string|int, mixed>
$uniqueAttributes
= array()
Tags
$updated_by
The ID of the person who last updated this record.
protected
Integer
$updated_by
Tags
$updated_ts
The timestamp of the last update.
protected
Timestamp
$updated_ts
Tags
$validationRule
The validation rule for the Sequence type.
protected
string
$validationRule
Tags
$version_num
The version number of the object, used for locking mechanism.
protected
Integer
$version_num
Tags
$logger
Trace logger.
private
static Logger
$logger
= null
Tags
$maintainHistory
Determines if we will maintain a _history table for this record (default is false).
private
bool
$maintainHistory
= false
Tags
Methods
__construct()
The constructor.
public
__construct() : mixed
Tags
__toString()
Used to convert the object to a printable string.
public
__toString() : string
Tags
Return values
string__wakeup()
Re-initialize the static logger property on the Record after de-serialize, as PHP does not serialize static properties.
public
__wakeup() : void
Tags
addProperty()
Adds in a new class property without loosing existing data (does an ALTER TABLE query on the database).
public
addProperty(string $propName) : void
Parameters
- $propName : string
-
The name of the new field to add to the database table.
Tags
addToCache()
Stores the business object to the configured cache instance.
public
addToCache() : void
Tags
backupDatabase()
Backup the configured database.
public
static backupDatabase(string $targetFile) : void
Parameters
- $targetFile : string
-
The file that the backup data will be written to.
Tags
begin()
Starts a new database transaction.
public
static begin([ActiveRecord|null $record = null ]) : void
Parameters
- $record : ActiveRecord|null = null
-
The ActiveRecord instance to pass to the database provider. Leave empty to have a new Person passed.
Tags
cast()
Cast a Record to another type of record. A new Record will be returned with the same ID and version_num as the old record, so this is NOT a true cast but is a copy. All attribute values will be copied accross.
public
cast(string $targetClassName, ActiveRecord $originalRecord) : ActiveRecord
Parameters
- $targetClassName : string
-
The fully-qualified name of the target Record class.
- $originalRecord : ActiveRecord
-
The original business object.
Tags
Return values
ActiveRecordcheckDatabaseExists()
Check to see if the configured database exists.
public
static checkDatabaseExists() : bool
Tags
Return values
boolcheckRecordExists()
Checks that a record exists for the Record in the database.
public
checkRecordExists(int $ID) : bool
Parameters
- $ID : int
-
The Object ID of the object we want to see whether it exists or not.
Tags
Return values
boolcheckRecordTableExists()
Static method to check the database and see if the table for the indicated Record class name exists (assumes table name will be $recordClassName less "Object").
public
static checkRecordTableExists(string $recordClassName[, bool $checkHistoryTable = false ]) : bool
Parameters
- $recordClassName : string
-
The name of the business object class we are checking.
- $checkHistoryTable : bool = false
-
Set to true if you want to check for the existance of the _history table for this DAO.
Tags
Return values
boolcheckTableExists()
Checks to see if the table exists in the database for the current business class.
public
checkTableExists([bool $checkHistoryTable = false ]) : bool
Parameters
- $checkHistoryTable : bool = false
-
Set to true if you want to check for the existance of the _history table for this DAO.
Tags
Return values
boolcheckTableNeedsUpdate()
Checks to see if the table in the database matches (for fields) the business class definition, i.e. if the database table is in sync with the class definition.
public
checkTableNeedsUpdate() : bool
Tags
Return values
boolcommit()
Commits the current database transaction.
public
static commit([ActiveRecord|null $record = null ]) : void
Parameters
- $record : ActiveRecord|null = null
-
The ActiveRecord instance to pass to the database provider. Leave empty to have a new Person passed.
Tags
createDatabase()
Creates the configured database.
public
static createDatabase() : void
Tags
createForeignIndex()
Creates a foreign key constraint (index) in the database on the given attribute.
public
createForeignIndex(string $attributeName, string $relatedClass, string $relatedClassAttribute[, string $indexName = null ]) : void
Parameters
- $attributeName : string
-
The name of the attribute to apply the index on.
- $relatedClass : string
-
The name of the related class in the format "NameObject".
- $relatedClassAttribute : string
-
The name of the field to relate to on the related class.
- $indexName : string = null
-
The optional name for the index, will calculate if not provided.
Tags
createUniqueIndex()
Creates a unique index in the database on the given attribute(s).
public
createUniqueIndex(string $attribute1Name[, string $attribute2Name = '' ][, string $attribute3Name = '' ]) : void
Parameters
- $attribute1Name : string
-
The first attribute to mark unique in the database.
- $attribute2Name : string = ''
-
The second attribute to mark unique in the databse (optional, use only for composite keys).
- $attribute3Name : string = ''
-
The third attribute to mark unique in the databse (optional, use only for composite keys).
Tags
delete()
Deletes the current object from the database.
public
delete() : void
Tags
deleteAllByAttribute()
Delete all object instances from the database by the specified attribute matching the value provided. Returns the count of deleted records.
public
deleteAllByAttribute(string $attribute, mixed $value) : int
Parameters
- $attribute : string
-
The name of the field to delete the objects by.
- $value : mixed
-
The value of the field to delete the objects by.
Tags
Return values
intdisconnect()
Disconnects the current database connection if one exists.
public
static disconnect() : void
Tags
dropDatabase()
Drops the configured database.
public
static dropDatabase() : void
Tags
dropTable()
Drops the table if the model requirements have changed. All data is lost!
public
dropTable([string|null $tableName = null ]) : void
Parameters
- $tableName : string|null = null
-
Optional table name, leave blank for the defined table for this class to be dropped
Tags
findMissingFields()
Returns an array containing any properties on the class which have not been created on the database table yet.
public
findMissingFields() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>get()
Generic getter method for accessing class properties. Will use the method get.ucfirst($prop) instead if that method exists at a child level (by default). Set $noChildMethods to true if you don't want to use any get.ucfirst($prop) method even if it exists, false otherwise (default).
public
get(string $prop[, bool $noChildMethods = false ]) : mixed
Parameters
- $prop : string
-
The name of the object property to get.
- $noChildMethods : bool = false
-
Set to true if you do not want to use getters in the child object, defaults to false.
Tags
getCount()
Gets the count from the database for the amount of objects of this class.
public
getCount([array<string|int, mixed> $attributes = array() ][, array<string|int, mixed> $values = array() ]) : int
Parameters
- $attributes : array<string|int, mixed> = array()
-
The attributes to count the objects by (optional).
- $values : array<string|int, mixed> = array()
-
The values of the attributes to count the objects by (optional).
Tags
Return values
intgetCreateTS()
Method for getting the date/time of when the Record was created.
public
getCreateTS() : Timestamp
Tags
Return values
TimestampgetCreatorId()
Method for getting the ID of the person who created this record.
public
getCreatorId() : Integer
Tags
Return values
IntegergetDataLabel()
Gets the data label for the given attribute name.
public
getDataLabel(string $att) : string
Parameters
- $att : string
-
The attribute name to get the label for.
Tags
Return values
stringgetDataLabels()
Gets the data labels array.
public
getDataLabels() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>getDefaultAttributes()
Get the array of default attribute names.
public
getDefaultAttributes() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>getFriendlyClassName()
Returns the simple class name, stripped of the namespace.
public
getFriendlyClassName() : string
Tags
Return values
stringgetHelper()
Getter for the validation helper string.
public
getHelper() : string
Tags
Return values
stringgetHistoryCount()
Gets the count from the database for the amount of entries in the [tableName]_history table for this business object. Only call this method on classes where maintainHistory = true, otherwise an exception will be thrown.
public
getHistoryCount() : int
Tags
Return values
intgetID()
Gets the ID for the object in 11 digit zero-padded format (same as getID()).
public
final getID() : string
Tags
Return values
stringgetIndexes()
Gets an array of all of the names of the active database indexes for this class.
public
getIndexes() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>getLastQuery()
Get the last database query run on this object.
public
getLastQuery() : string
Tags
Return values
stringgetMaintainHistory()
Gets the value of the maintainHistory attribute.
public
getMaintainHistory() : bool
Tags
Return values
boolgetMAX()
Gets the maximum ID value from the database for this class type.
public
getMAX() : int
Tags
Return values
intgetPersistentAttributes()
Get the array of persistent attribute names, i.e. those that are saved in the database.
public
getPersistentAttributes() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>getPropObject()
Gets the property object rather than the value for complex attributes. Returns false if the property exists but is private.
public
getPropObject(string $prop) : mixed
Parameters
- $prop : string
-
The name of the property we are getting.
Tags
getRecordClassNames()
Loops over the core and custom Record directories and builds an array of all of the Record class names in the system.
public
static getRecordClassNames() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>getRule()
Get the validation rule.
public
getRule() : string
Tags
Return values
stringgetSize()
Get the allowable size of the Sequence in the database field.
public
getSize() : int
Tags
Return values
intgetTableName()
Getter for the TABLE_NAME, the name of the table in the database for this class, which should be set by a child of this class.
public
getTableName() : string
Tags
Return values
stringgetTaggedAttributes()
Returns the contents of the taggedAttributes array, or an empty array if that does not exist.
public
getTaggedAttributes() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>getTransientAttributes()
Get the array of transient attribute names.
public
getTransientAttributes() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>getUniqueAttributes()
Returns the array of names of unique attributes on this record.
public
getUniqueAttributes() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>getUpdateTS()
Method for getting the date/time of when the Record was last updated.
public
getUpdateTS() : Timestamp
Tags
Return values
TimestampgetUpdatorId()
Method for getting the ID of the person who updated this record.
public
getUpdatorId() : Integer
Tags
Return values
IntegergetValue()
Used to get the Sequence value as a string.
public
getValue() : string
Tags
Return values
stringgetVersion()
Gets the version_num of the object from the database (returns 0 if the Record is not saved yet).
public
getVersion() : int
Tags
Return values
intgetVersionNumber()
Method for getting version number of the object.
public
getVersionNumber() : Integer
Tags
Return values
IntegerhasAttribute()
Check to see if an attribute exists on the record.
public
hasAttribute(string $attribute) : bool
Parameters
- $attribute : string
-
The attribute name.
Tags
Return values
boolisInstalled()
Static method that tries to determine if the system database has been installed or not.
public
static isInstalled() : bool
Tags
Return values
boolisTableOverloaded()
Checks to see if the table name matches the classname, and if not if the table name matches the classname name of another record, i.e. the table is used to store multiple types of records.
public
isTableOverloaded() : bool
Tags
Return values
boolisTagged()
Returns true if the Record has a Relation property called tags, false otherwise.
public
isTagged() : bool
Tags
Return values
boolisTransient()
Inspector to see if the business object is transient (not presently stored in the database).
public
isTransient() : bool
Tags
Return values
boolload()
Populates the child object with the properties retrived from the database for the object $ID.
public
load(int $ID[, int $version = 0 ]) : void
Parameters
- $ID : int
-
The object ID of the business object to load.
- $version : int = 0
-
Optionaly, provide the version to load that version from the [tablename]_history table.
Tags
loadAll()
Loads all of the objects of this class into an array which is returned.
public
loadAll([int $start = 0 ][, int $limit = 0 ][, string $orderBy = 'ID' ][, string $order = 'ASC' ][, bool $ignoreClassType = false ]) : array<string|int, mixed>
Parameters
- $start : int = 0
-
The start of the SQL LIMIT clause, useful for pagination.
- $limit : int = 0
-
The amount (limit) of objects to load, useful for pagination.
- $orderBy : string = 'ID'
-
The name of the field to sort the objects by.
- $order : string = 'ASC'
-
The order to sort the objects by.
- $ignoreClassType : bool = false
-
Default is false, set to true if you want to load from overloaded tables and ignore the class type
Tags
Return values
array<string|int, mixed>loadAllByAttribute()
Loads all of the objects of this class by the specified attribute into an array which is returned.
public
loadAllByAttribute(string $attribute, string $value[, int $start = 0 ][, int $limit = 0 ][, string $orderBy = 'ID' ][, string $order = 'ASC' ][, bool $ignoreClassType = false ][, array<string|int, mixed> $constructorArgs = array() ]) : array<string|int, mixed>
Parameters
- $attribute : string
-
The attribute to load the objects by.
- $value : string
-
The value of the attribute to load the objects by.
- $start : int = 0
-
The start of the SQL LIMIT clause, useful for pagination.
- $limit : int = 0
-
The amount (limit) of objects to load, useful for pagination.
- $orderBy : string = 'ID'
-
The name of the field to sort the objects by.
- $order : string = 'ASC'
-
The order to sort the objects by.
- $ignoreClassType : bool = false
-
Default is false, set to true if you want to load from overloaded tables and ignore the class type.
- $constructorArgs : array<string|int, mixed> = array()
-
An optional array of contructor arguements to pass to the records that will be generated and returned. Supports a maximum of 5 arguements.
Tags
Return values
array<string|int, mixed>loadAllByAttributes()
Loads all of the objects of this class by the specified attributes into an array which is returned.
public
loadAllByAttributes([array<string|int, mixed> $attributes = array() ][, array<string|int, mixed> $values = array() ][, int $start = 0 ][, int $limit = 0 ][, string $orderBy = 'ID' ][, string $order = 'ASC' ][, bool $ignoreClassType = false ]) : array<string|int, mixed>
Parameters
- $attributes : array<string|int, mixed> = array()
-
The attributes to load the objects by.
- $values : array<string|int, mixed> = array()
-
The values of the attributes to load the objects by.
- $start : int = 0
-
The start of the SQL LIMIT clause, useful for pagination.
- $limit : int = 0
-
The amount (limit) of objects to load, useful for pagination.
- $orderBy : string = 'ID'
-
The name of the field to sort the objects by.
- $order : string = 'ASC'
-
The order to sort the objects by.
- $ignoreClassType : bool = false
-
Default is false, set to true if you want to load from overloaded tables and ignore the class type
Tags
Return values
array<string|int, mixed>loadAllByDayUpdated()
Loads all of the objects of this class that where updated (updated_ts value) on the date indicated.
public
loadAllByDayUpdated(string $date[, int $start = 0 ][, int $limit = 0 ][, string $orderBy = 'ID' ][, string $order = 'ASC' ][, bool $ignoreClassType = false ]) : array<string|int, mixed>
Parameters
- $date : string
-
The date for which to load the objects updated on, in the format 'YYYY-MM-DD'.
- $start : int = 0
-
The start of the SQL LIMIT clause, useful for pagination.
- $limit : int = 0
-
The amount (limit) of objects to load, useful for pagination.
- $orderBy : string = 'ID'
-
The name of the field to sort the objects by.
- $order : string = 'ASC'
-
The order to sort the objects by.
- $ignoreClassType : bool = false
-
Default is false, set to true if you want to load from overloaded tables and ignore the class type
Tags
Return values
array<string|int, mixed>loadAllFieldValuesByAttribute()
Loads all of the specified attribute values of this class by the specified attribute into an array which is returned.
public
loadAllFieldValuesByAttribute(string $attribute, string $value, string $returnAttribute[, string $order = 'ASC' ][, bool $ignoreClassType = false ]) : array<string|int, mixed>
Parameters
- $attribute : string
-
The attribute name to load the field values by.
- $value : string
-
The value of the attribute to load the field values by.
- $returnAttribute : string
-
The name of the attribute to return.
- $order : string = 'ASC'
-
The order to sort the records by.
- $ignoreClassType : bool = false
-
Default is false, set to true if you want to load from overloaded tables and ignore the class type.
Tags
Return values
array<string|int, mixed>loadAllOldVersions()
Load all old versions (if any) of this record from the [tablename]_history table.
public
loadAllOldVersions(int $ID) : array<string|int, mixed>
Parameters
- $ID : int
-
The object ID of the record to load.
Tags
Return values
array<string|int, mixed>loadByAttribute()
Populates the child object from the database table by the given attribute value.
public
loadByAttribute(string $attribute, string $value[, bool $ignoreClassType = false ][, array<string|int, mixed> $loadAttributes = array() ]) : void
Parameters
- $attribute : string
-
The name of the attribute to load the object by.
- $value : string
-
The value of the attribute to load the object by.
- $ignoreClassType : bool = false
-
Default is false, set to true if you want to load from overloaded tables and ignore the class type
- $loadAttributes : array<string|int, mixed> = array()
-
The attributes to load from the database to this object (leave blank to load all attributes)
Tags
loadFromCache()
Attempts to load the business object from the configured cache instance, returns true on a cache hit.
public
loadFromCache() : bool
Tags
Return values
boolmakeHistoryTable()
Builds a new database table for the Record class to story it's history of changes.
public
makeHistoryTable() : void
Tags
makeTable()
Builds a new database table for the Record class.
public
makeTable([bool $checkIndexes = true ]) : void
Parameters
- $checkIndexes : bool = true
Tags
markPersistent()
Removes the name of the attribute provided from the list of transient (non-saved) attributes for this record, ensuring that it will be saved on the next attempt.
public
markPersistent(string $attributeName) : void
Parameters
- $attributeName : string
-
The name of the attribute to save.
Tags
markTransient()
Adds the name of the attribute provided to the list of transient (non-saved) attributes for this record.
public
markTransient(string $attributeName) : void
Parameters
- $attributeName : string
-
The name of the attribute to not save.
Tags
populateFromArray()
Populates the current business object from the provided hash array.
public
populateFromArray(array<string|int, mixed> $hashArray) : void
Parameters
- $hashArray : array<string|int, mixed>
Tags
query()
Returns a 2d array, where each element in the array is another array representing a database row.
public
query(string $sqlQuery) : array<string|int, mixed>
Parameters
- $sqlQuery : string
Tags
Return values
array<string|int, mixed>rebuildTable()
Re-builds the table if the model requirements have changed. All data is lost!
public
rebuildTable() : void
Tags
reload()
Reloads the object from the database, overwritting any attribute values in memory.
public
reload() : void
Tags
removeFromCache()
Removes the business object from the configured cache instance.
public
removeFromCache() : void
Tags
rollback()
Aborts the current database transaction.
public
static rollback([ActiveRecord|null $record = null ]) : void
Parameters
- $record : ActiveRecord|null = null
-
The ActiveRecord instance to pass to the database provider. Leave empty to have a new Person passed.
Tags
save()
Saves the object. If $this->ID is empty or null it will INSERT, otherwise UPDATE.
public
save() : void
Tags
saveAttribute()
Saves the field specified with the value supplied. Only works for persistent records. Note that no Alpha type validation is performed with this method!
public
saveAttribute(string $attribute, mixed $value) : void
Parameters
- $attribute : string
-
The name of the attribute to save.
- $value : mixed
-
The value of the attribute to save.
Tags
saveHistory()
Saves the history of the object in the [tablename]_history table. It will always perform an insert.
public
saveHistory() : void
Tags
saveRelations()
Saves relationship values, including lookup entries, for this record.
public
saveRelations() : void
Tags
set()
Generic setter method for setting class properties. Will use the method set.ucfirst($prop) instead if that method exists at a child level (by default). Set $noChildMethods to true if you don't want to use any get.ucfirst($prop) method even if it exists, false otherwise (default).
public
set(string $prop, mixed $value[, bool $noChildMethods = false ]) : void
Parameters
- $prop : string
-
The name of the property to set.
- $value : mixed
-
The value of the property to set.
- $noChildMethods : bool = false
-
Set to true if you do not want to use setters in the child object, defaults to false.
Tags
setDataLabels()
Sets the data labels array.
public
setDataLabels(array<string|int, mixed> $labels) : void
Parameters
- $labels : array<string|int, mixed>
Tags
setHelper()
Set the validation helper text.
public
setHelper(string $helper) : void
Parameters
- $helper : string
Tags
setID()
Setter for the Object ID (ID).
public
setID(int $ID) : void
Parameters
- $ID : int
-
The Object ID.
Tags
setLastQuery()
Sets the last query executed on this business object.
public
setLastQuery(string $query) : void
Parameters
- $query : string
Tags
setMaintainHistory()
Sets maintainHistory attribute on this DAO.
public
setMaintainHistory(bool $maintainHistory) : void
Parameters
- $maintainHistory : bool
Tags
setSequenceToNext()
Sets the sequence number to be the maximum value matching the prefix in the database plus one. Note that calling this method increments the maximum value in the database.
public
setSequenceToNext() : void
Tags
setValue()
Accepts a string to set the Sequence prefix/sequence values to, in the format PREFIX-00000000000.
public
setValue(mixed $val) : void
Parameters
- $val : mixed
Tags
toArray()
Return a hash array of the object containing attribute names and simplfied values.
public
toArray() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>markUnique()
Adds the name of the attribute(s) provided to the list of unique (constrained) attributes for this record.
protected
markUnique(string $attribute1Name[, string $attribute2Name = '' ][, string $attribute3Name = '' ]) : void
Parameters
- $attribute1Name : string
-
The first attribute to mark unique in the database.
- $attribute2Name : string = ''
-
The second attribute to mark unique in the databse (optional, use only for composite keys).
- $attribute3Name : string = ''
-
The third attribute to mark unique in the databse (optional, use only for composite keys).
Tags
setEnumOptions()
Populate all of the enum options for this object from the database.
protected
setEnumOptions() : void
Tags
validate()
Validates the object to be saved.
protected
validate() : void
Tags
clear()
Unsets all of the attributes of this object to null.
private
clear() : void
Tags
setVersion()
Setter for the Record version number.
private
setVersion(int $versionNumber) : void
Parameters
- $versionNumber : int
-
The version number.