ArticleComment extends ActiveRecord
An article comment class for user comments.
Tags
Table of Contents
- TABLE_NAME = 'ArticleComment'
- The name of the database table for the class.
- $articleID : Relation
- The article this comment belongs to.
- $content : Text
- The content of the comment posted by the user.
- $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.
- $ID : int
- The object ID.
- $lastQuery : string
- The last database query run by this object. Useful for tracing an error.
- $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.
- $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).
- __construct() : mixed
- constructor for the class.
- __wakeup() : mixed
- Re-initialize the static logger property on the Record after de-serialize, as PHP does not serialize static properties.
- addProperty() : mixed
- Adds in a new class property without loosing existing data (does an ALTER TABLE query on the database).
- addToCache() : mixed
- Stores the business object to the configured cache instance.
- backupDatabase() : mixed
- Backup the configured database.
- begin() : mixed
- 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() : mixed
- Commits the current database transaction.
- createDatabase() : mixed
- Creates the configured database.
- createForeignIndex() : mixed
- Creates a foreign key constraint (index) in the database on the given attribute.
- createUniqueIndex() : mixed
- Creates a unique index in the database on the given attribute(s).
- delete() : mixed
- Deletes the current object from the database.
- deleteAllByAttribute() : int
- Delete all object instances from the database by the specified attribute matching the value provided.
- disconnect() : mixed
- Disconnects the current database connection if one exists.
- dropDatabase() : mixed
- Drops the configured database.
- dropTable() : mixed
- 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.
- 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 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() : Type|bool
- 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.
- getTableName() : string
- Getter for the TABLE_NAME, 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.
- 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() : mixed
- 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() : mixed
- 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.
- makeHistoryTable() : mixed
- Builds a new database table for the Record class to story it's history of changes.
- makeTable() : mixed
- Builds a new database table for the Record class.
- markPersistent() : mixed
- 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() : mixed
- Adds the name of the attribute provided to the list of transient (non-saved) attributes for this record.
- populateFromArray() : mixed
- 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() : mixed
- Re-builds the table if the model requirements have changed. All data is lost!
- reload() : mixed
- Reloads the object from the database, overwritting any attribute values in memory.
- removeFromCache() : mixed
- Removes the business object from the configured cache instance.
- rollback() : mixed
- Aborts the current database transaction.
- save() : mixed
- Saves the object. If $this->ID is empty or null it will INSERT, otherwise UPDATE.
- saveAttribute() : mixed
- 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() : mixed
- Saves the history of the object in the [tablename]_history table. It will always perform an insert.
- saveRelations() : mixed
- Saves relationship values, including lookup entries, for this record.
- set() : mixed
- 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() : mixed
- Sets the data labels array.
- setID() : mixed
- Setter for the Object ID (ID).
- setLastQuery() : mixed
- Sets the last query executed on this business object.
- setMaintainHistory() : mixed
- Sets maintainHistory attribute on this DAO.
- toArray() : array<string|int, mixed>
- Return a hash array of the object containing attribute names and simplfied values.
- markUnique() : mixed
- Adds the name of the attribute(s) provided to the list of unique (constrained) attributes for this record.
- setEnumOptions() : mixed
- Populate all of the enum options for this object from the database.
- validate() : mixed
- Validates the object to be saved.
- clear() : mixed
- Unsets all of the attributes of this object to null.
- setVersion() : mixed
- Setter for the Record version number.
Constants
TABLE_NAME
The name of the database table for the class.
public
string
TABLE_NAME
= 'ArticleComment'
Tags
Properties
$articleID
The article this comment belongs to.
protected
Relation
$articleID
Tags
$content
The content of the comment posted by the user.
protected
Text
$content
Tags
$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' => 'Article Comment ID#', 'articleID' => 'Article', 'content' => 'Comment')
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
$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
$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
$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()
constructor for the class.
public
__construct() : mixed
Tags
Return values
mixed —__wakeup()
Re-initialize the static logger property on the Record after de-serialize, as PHP does not serialize static properties.
public
__wakeup() : mixed
Tags
Return values
mixed —addProperty()
Adds in a new class property without loosing existing data (does an ALTER TABLE query on the database).
public
addProperty(string $propName) : mixed
Parameters
- $propName : string
-
The name of the new field to add to the database table.
Tags
Return values
mixed —addToCache()
Stores the business object to the configured cache instance.
public
addToCache() : mixed
Tags
Return values
mixed —backupDatabase()
Backup the configured database.
public
static backupDatabase(string $targetFile) : mixed
Parameters
- $targetFile : string
-
The file that the backup data will be written to.
Tags
Return values
mixed —begin()
Starts a new database transaction.
public
static begin([ActiveRecord $record = null ]) : mixed
Parameters
- $record : ActiveRecord = null
-
The ActiveRecord instance to pass to the database provider. Leave empty to have a new Person passed.
Tags
Return values
mixed —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
ActiveRecord —The new business object resulting from the cast.
checkDatabaseExists()
Check to see if the configured database exists.
public
static checkDatabaseExists() : bool
Tags
Return values
bool —checkRecordExists()
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
bool —checkRecordTableExists()
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
bool —checkTableExists()
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
bool —checkTableNeedsUpdate()
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
bool —commit()
Commits the current database transaction.
public
static commit([ActiveRecord $record = null ]) : mixed
Parameters
- $record : ActiveRecord = null
-
The ActiveRecord instance to pass to the database provider. Leave empty to have a new Person passed.
Tags
Return values
mixed —createDatabase()
Creates the configured database.
public
static createDatabase() : mixed
Tags
Return values
mixed —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 ]) : mixed
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
Return values
mixed —createUniqueIndex()
Creates a unique index in the database on the given attribute(s).
public
createUniqueIndex(string $attribute1Name[, string $attribute2Name = '' ][, string $attribute3Name = '' ]) : mixed
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
Return values
mixed —delete()
Deletes the current object from the database.
public
delete() : mixed
Tags
Return values
mixed —deleteAllByAttribute()
Delete all object instances from the database by the specified attribute matching the value provided.
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
int —The number of rows deleted.
disconnect()
Disconnects the current database connection if one exists.
public
static disconnect() : mixed
Tags
Return values
mixed —dropDatabase()
Drops the configured database.
public
static dropDatabase() : mixed
Tags
Return values
mixed —dropTable()
Drops the table if the model requirements have changed. All data is lost!
public
dropTable([string $tableName = null ]) : mixed
Parameters
- $tableName : string = null
-
Optional table name, leave blank for the defined table for this class to be dropped
Tags
Return values
mixed —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> —An array of missing fields in the database table.
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
Return values
mixed —The property value.
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
int —getCreateTS()
Method for getting the date/time of when the Record was created.
public
getCreateTS() : Timestamp
Tags
Return values
Timestamp —getCreatorId()
Method for getting the ID of the person who created this record.
public
getCreatorId() : Integer
Tags
Return values
Integer —The ID of the creator.
getDataLabel()
Gets the data label for the given attribute name.
public
getDataLabel( $att) : string
Parameters
Tags
Return values
string —getDataLabels()
Gets the data labels array.
public
getDataLabels() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —An array of attribute labels.
getDefaultAttributes()
Get the array of default attribute names.
public
getDefaultAttributes() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —An array of attribute names.
getFriendlyClassName()
Returns the simple class name, stripped of the namespace.
public
getFriendlyClassName() : string
Tags
Return values
string —getHistoryCount()
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
int —getID()
Gets the ID for the object in zero-padded format (same as getID()).
public
final getID() : string
Tags
Return values
string —11 digit zero-padded ID value.
getIndexes()
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> —An array of database indexes on this table.
getLastQuery()
Get the last database query run on this object.
public
getLastQuery() : string
Tags
Return values
string —An SQL query string.
getMaintainHistory()
Gets the value of the maintainHistory attribute.
public
getMaintainHistory() : bool
Tags
Return values
bool —getMAX()
Gets the maximum ID value from the database for this class type.
public
getMAX() : int
Tags
Return values
int —The maximum ID value in the class table.
getPersistentAttributes()
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> —An array of attribute names.
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) : Type|bool
Parameters
- $prop : string
-
The name of the property we are getting.
Tags
Return values
Type|bool —The complex type object found.
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> —An array of business object class names.
getTableName()
Getter for the TABLE_NAME, which should be set by a child of this class.
public
getTableName() : string
Tags
Return values
string —The table name in the database.
getTaggedAttributes()
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> —An array of attribute names.
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
Timestamp —getUpdatorId()
Method for getting the ID of the person who updated this record.
public
getUpdatorId() : Integer
Tags
Return values
Integer —The ID of the updator.
getVersion()
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
int —getVersionNumber()
Method for getting version number of the object.
public
getVersionNumber() : Integer
Tags
Return values
Integer —The object version number.
hasAttribute()
Check to see if an attribute exists on the record.
public
hasAttribute(string $attribute) : bool
Parameters
- $attribute : string
-
The attribute name.
Tags
Return values
bool —isInstalled()
Static method that tries to determine if the system database has been installed or not.
public
static isInstalled() : bool
Tags
Return values
bool —isTableOverloaded()
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
bool —isTagged()
Returns true if the Record has a Relation property called tags, false otherwise.
public
isTagged() : bool
Tags
Return values
bool —isTransient()
Inspector to see if the business object is transient (not presently stored in the database).
public
isTransient() : bool
Tags
Return values
bool —load()
Populates the child object with the properties retrived from the database for the object $ID.
public
load(int $ID, int $version) : mixed
Parameters
- $ID : int
-
The object ID of the business object to load.
- $version : int
-
Optionaly, provide the version to load that version from the [tablename]_history table.
Tags
Return values
mixed —loadAll()
Loads all of the objects of this class into an array which is returned.
public
loadAll(int $start, int $limit[, string $orderBy = 'ID' ][, string $order = 'ASC' ][, bool $ignoreClassType = false ]) : array<string|int, mixed>
Parameters
- $start : int
-
The start of the SQL LIMIT clause, useful for pagination.
- $limit : int
-
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> —An array containing objects of this type of business object.
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, int $limit[, 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
-
The start of the SQL LIMIT clause, useful for pagination.
- $limit : int
-
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> —An array containing objects of this type of business object.
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, int $limit[, 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
-
The start of the SQL LIMIT clause, useful for pagination.
- $limit : int
-
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> —An array containing objects of this type of business object.
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, int $limit[, 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
-
The start of the SQL LIMIT clause, useful for pagination.
- $limit : int
-
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> —An array containing objects of this type of business object.
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> —An array of field values.
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> —An array containing objects of this type of record object, order by version.
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() ]) : mixed
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
Return values
mixed —loadFromCache()
Attempts to load the business object from the configured cache instance.
public
loadFromCache() : bool
Tags
Return values
bool —makeHistoryTable()
Builds a new database table for the Record class to story it's history of changes.
public
makeHistoryTable() : mixed
Tags
Return values
mixed —makeTable()
Builds a new database table for the Record class.
public
makeTable([mixed $checkIndexes = true ]) : mixed
Parameters
- $checkIndexes : mixed = true
Tags
Return values
mixed —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) : mixed
Parameters
- $attributeName : string
-
The name of the attribute to save.
Tags
Return values
mixed —markTransient()
Adds the name of the attribute provided to the list of transient (non-saved) attributes for this record.
public
markTransient(string $attributeName) : mixed
Parameters
- $attributeName : string
-
The name of the attribute to not save.
Tags
Return values
mixed —populateFromArray()
Populates the current business object from the provided hash array.
public
populateFromArray(array<string|int, mixed> $hashArray) : mixed
Parameters
- $hashArray : array<string|int, mixed>
Tags
Return values
mixed —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() : mixed
Tags
Return values
mixed —reload()
Reloads the object from the database, overwritting any attribute values in memory.
public
reload() : mixed
Tags
Return values
mixed —removeFromCache()
Removes the business object from the configured cache instance.
public
removeFromCache() : mixed
Tags
Return values
mixed —rollback()
Aborts the current database transaction.
public
static rollback([ActiveRecord $record = null ]) : mixed
Parameters
- $record : ActiveRecord = null
-
The ActiveRecord instance to pass to the database provider. Leave empty to have a new Person passed.
Tags
Return values
mixed —save()
Saves the object. If $this->ID is empty or null it will INSERT, otherwise UPDATE.
public
save() : mixed
Tags
Return values
mixed —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) : mixed
Parameters
- $attribute : string
-
The name of the attribute to save.
- $value : mixed
-
The value of the attribute to save.
Tags
Return values
mixed —saveHistory()
Saves the history of the object in the [tablename]_history table. It will always perform an insert.
public
saveHistory() : mixed
Tags
Return values
mixed —saveRelations()
Saves relationship values, including lookup entries, for this record.
public
saveRelations() : mixed
Tags
Return values
mixed —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 ]) : mixed
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
Return values
mixed —setDataLabels()
Sets the data labels array.
public
setDataLabels(array<string|int, mixed> $labels) : mixed
Parameters
- $labels : array<string|int, mixed>
Tags
Return values
mixed —setID()
Setter for the Object ID (ID).
public
setID(int $ID) : mixed
Parameters
- $ID : int
-
The Object ID.
Tags
Return values
mixed —setLastQuery()
Sets the last query executed on this business object.
public
setLastQuery(string $query) : mixed
Parameters
- $query : string
Tags
Return values
mixed —setMaintainHistory()
Sets maintainHistory attribute on this DAO.
public
setMaintainHistory(bool $maintainHistory) : mixed
Parameters
- $maintainHistory : bool
Tags
Return values
mixed —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 = '' ]) : mixed
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
Return values
mixed —setEnumOptions()
Populate all of the enum options for this object from the database.
protected
setEnumOptions() : mixed
Tags
Return values
mixed —validate()
Validates the object to be saved.
protected
validate() : mixed
Tags
Return values
mixed —clear()
Unsets all of the attributes of this object to null.
private
clear() : mixed
Tags
Return values
mixed —setVersion()
Setter for the Record version number.
private
setVersion(int $versionNumber) : mixed
Parameters
- $versionNumber : int
-
The version number.