Alpha Framework 4.0.0 API Documentation

BlacklistedClient extends ActiveRecord
in package

A HTTP client that is blacklisted from accessing this application.

Tags
since
1.0
author

John Collins dev@alphaframework.org

license

http://www.opensource.org/licenses/bsd-license.php The BSD License

copyright

Copyright (c) 2021, John Collins (founder of Alpha Framework). All rights reserved.

Redistribution and use in source and binary forms, with or
without modification, are permitted provided that the
following conditions are met:

* Redistributions of source code must retain the above
  copyright notice, this list of conditions and the
  following disclaimer.
* Redistributions in binary form must reproduce the above
  copyright notice, this list of conditions and the
  following disclaimer in the documentation and/or other
  materials provided with the distribution.
* Neither the name of the Alpha Framework nor the names
  of its contributors may be used to endorse or promote
  products derived from this software without specific
  prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Table of Contents

Constants

TABLE_NAME  = 'BlacklistedClient'
The name of the database table for the class.

Properties

$client  : SmallText
The (unique) client string this is blocked.
$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).

Methods

__construct()  : mixed
Constructor for the class.
__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.
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.
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.
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.
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.
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

TABLE_NAME

The name of the database table for the class.

public string TABLE_NAME = 'BlacklistedClient'
Tags
since
1.0

Properties

$created_by

The ID of the person who created this record.

protected Integer $created_by
Tags
since
1.0

$dataLabels

An array of data display labels for the class properties.

protected array<string|int, mixed> $dataLabels = array('ID' => 'Blacklisted Client ID#', 'client' => 'Client string')
Tags
since
1.0

$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
since
1.0

$lastQuery

The last database query run by this object. Useful for tracing an error.

protected string $lastQuery = ''
Tags
since
1.0

$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
since
1.0

$uniqueAttributes

An array of the uniquely-constained attributes of this persistent record.

protected array<string|int, mixed> $uniqueAttributes = array()
Tags
since
1.0

$updated_by

The ID of the person who last updated this record.

protected Integer $updated_by
Tags
since
1.0

$version_num

The version number of the object, used for locking mechanism.

protected Integer $version_num
Tags
since
1.0

$maintainHistory

Determines if we will maintain a _history table for this record (default is false).

private bool $maintainHistory = false
Tags
since
1.2

Methods

__construct()

Constructor for the class.

public __construct() : mixed
Tags
since
1.0

__wakeup()

Re-initialize the static logger property on the Record after de-serialize, as PHP does not serialize static properties.

public __wakeup() : void
Tags
since
1.2

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
since
1.0
throws
AlphaException

addToCache()

Stores the business object to the configured cache instance.

public addToCache() : void
Tags
since
1.1

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
throws
AlphaException
since
3.0

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
since
1.0
throws
AlphaException

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
since
1.0
Return values
ActiveRecord

checkDatabaseExists()

Check to see if the configured database exists.

public static checkDatabaseExists() : bool
Tags
since
2.0
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
since
1.0
throws
AlphaException
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
since
1.0
throws
AlphaException
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
since
1.0
throws
AlphaException
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
since
1.0
throws
AlphaException
Return values
bool

commit()

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
since
1.0
throws
FailedSaveException

createDatabase()

Creates the configured database.

public static createDatabase() : void
Tags
throws
AlphaException
since
2.0

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
since
1.0
throws
FailedIndexCreateException

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
since
1.0
throws
FailedIndexCreateException

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
since
1.0
throws
FailedDeleteException
Return values
int

disconnect()

Disconnects the current database connection if one exists.

public static disconnect() : void
Tags
since
1.0

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
since
1.0
throws
AlphaException

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
since
1.0
throws
AlphaException
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
since
1.0
throws
IllegalArguementException
throws
AlphaException

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
since
1.0
throws
AlphaException
throws
IllegalArguementException
Return values
int

getCreateTS()

Method for getting the date/time of when the Record was created.

public getCreateTS() : Timestamp
Tags
since
1.0
Return values
Timestamp

getCreatorId()

Method for getting the ID of the person who created this record.

public getCreatorId() : Integer
Tags
since
1.0
Return values
Integer

getDataLabel()

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
since
1.0
throws
IllegalArguementException
Return values
string

getDataLabels()

Gets the data labels array.

public getDataLabels() : array<string|int, mixed>
Tags
since
1.0
Return values
array<string|int, mixed>

getDefaultAttributes()

Get the array of default attribute names.

public getDefaultAttributes() : array<string|int, mixed>
Tags
since
1.0
Return values
array<string|int, mixed>

getFriendlyClassName()

Returns the simple class name, stripped of the namespace.

public getFriendlyClassName() : string
Tags
since
1.0
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
since
1.2
throws
AlphaException
Return values
int

getID()

Gets the ID for the object in 11 digit zero-padded format (same as getID()).

public final getID() : string
Tags
since
1.0
Return values
string

getIndexes()

Gets an array of all of the names of the active database indexes for this class.

public getIndexes() : array<string|int, mixed>
Tags
since
1.0
throws
AlphaException
Return values
array<string|int, mixed>

getLastQuery()

Get the last database query run on this object.

public getLastQuery() : string
Tags
since
1.0
Return values
string

getMaintainHistory()

Gets the value of the maintainHistory attribute.

public getMaintainHistory() : bool
Tags
since
1.2
Return values
bool

getMAX()

Gets the maximum ID value from the database for this class type.

public getMAX() : int
Tags
since
1.0
throws
AlphaException
Return values
int

getPersistentAttributes()

Get the array of persistent attribute names, i.e. those that are saved in the database.

public getPersistentAttributes() : array<string|int, mixed>
Tags
since
1.0
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
since
1.0
throws
IllegalArguementException

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
since
1.0
Return values
array<string|int, mixed>

getTableName()

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
since
1.0
throws
AlphaException
Return values
string

getTaggedAttributes()

Returns the contents of the taggedAttributes array, or an empty array if that does not exist.

public getTaggedAttributes() : array<string|int, mixed>
Tags
since
1.2.3
Return values
array<string|int, mixed>

getTransientAttributes()

Get the array of transient attribute names.

public getTransientAttributes() : array<string|int, mixed>
Tags
since
1.0
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
since
1.1
Return values
array<string|int, mixed>

getUpdateTS()

Method for getting the date/time of when the Record was last updated.

public getUpdateTS() : Timestamp
Tags
since
1.0
Return values
Timestamp

getUpdatorId()

Method for getting the ID of the person who updated this record.

public getUpdatorId() : Integer
Tags
since
1.0
Return values
Integer

getVersion()

Gets the version_num of the object from the database (returns 0 if the Record is not saved yet).

public getVersion() : int
Tags
since
1.0
throws
RecordNotFoundException
Return values
int

getVersionNumber()

Method for getting version number of the object.

public getVersionNumber() : Integer
Tags
since
1.0
Return values
Integer

hasAttribute()

Check to see if an attribute exists on the record.

public hasAttribute(string $attribute) : bool
Parameters
$attribute : string

The attribute name.

Tags
since
1.0
Return values
bool

isInstalled()

Static method that tries to determine if the system database has been installed or not.

public static isInstalled() : bool
Tags
since
1.0
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
since
1.0
throws
BadTableNameException
Return values
bool

isTagged()

Returns true if the Record has a Relation property called tags, false otherwise.

public isTagged() : bool
Tags
since
1.0
Return values
bool

isTransient()

Inspector to see if the business object is transient (not presently stored in the database).

public isTransient() : bool
Tags
since
1.0
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 = 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
since
1.0
throws
RecordNotFoundException

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
since
1.0
throws
RecordNotFoundException
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
since
1.0
throws
RecordNotFoundException
throws
IllegalArguementException
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
since
1.0
throws
RecordNotFoundException
throws
IllegalArguementException
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
since
1.0
throws
RecordNotFoundException
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
since
1.0
throws
RecordNotFoundException
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
since
2.0
throws
RecordFoundException
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
since
1.0
throws
RecordNotFoundException

loadFromCache()

Attempts to load the business object from the configured cache instance, returns true on a cache hit.

public loadFromCache() : bool
Tags
since
1.1
Return values
bool

makeHistoryTable()

Builds a new database table for the Record class to story it's history of changes.

public makeHistoryTable() : void
Tags
since
1.2
throws
AlphaException

makeTable()

Builds a new database table for the Record class.

public makeTable([bool $checkIndexes = true ]) : void
Parameters
$checkIndexes : bool = true
Tags
since
1.0
throws
AlphaException

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
since
1.0

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
since
1.0

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
since
1.2.1

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
since
1.1
throws
CustomQueryException
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
since
1.0
throws
AlphaException

reload()

Reloads the object from the database, overwritting any attribute values in memory.

public reload() : void
Tags
since
1.0
throws
AlphaException

removeFromCache()

Removes the business object from the configured cache instance.

public removeFromCache() : void
Tags
since
1.1

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
since
1.0
throws
AlphaException

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
since
1.0
throws
IllegalArguementException
throws
FailedSaveException

saveHistory()

Saves the history of the object in the [tablename]_history table. It will always perform an insert.

public saveHistory() : void
Tags
since
1.2
throws
FailedSaveException

saveRelations()

Saves relationship values, including lookup entries, for this record.

public saveRelations() : void
Tags
since
3.0
throws
FailedSaveException

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
since
1.0
throws
AlphaException

setDataLabels()

Sets the data labels array.

public setDataLabels(array<string|int, mixed> $labels) : void
Parameters
$labels : array<string|int, mixed>
Tags
throws
IllegalArguementException
since
1.2

setID()

Setter for the Object ID (ID).

public setID(int $ID) : void
Parameters
$ID : int

The Object ID.

Tags
since
1.0

setLastQuery()

Sets the last query executed on this business object.

public setLastQuery(string $query) : void
Parameters
$query : string
Tags
since
1.1

setMaintainHistory()

Sets maintainHistory attribute on this DAO.

public setMaintainHistory(bool $maintainHistory) : void
Parameters
$maintainHistory : bool
Tags
throws
IllegalArguementException
since
1.2

toArray()

Return a hash array of the object containing attribute names and simplfied values.

public toArray() : array<string|int, mixed>
Tags
since
1.2.4
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
since
1.0

setEnumOptions()

Populate all of the enum options for this object from the database.

protected setEnumOptions() : void
Tags
since
1.0
throws
AlphaException

clear()

Unsets all of the attributes of this object to null.

private clear() : void
Tags
since
1.0

setVersion()

Setter for the Record version number.

private setVersion(int $versionNumber) : void
Parameters
$versionNumber : int

The version number.

Tags
since
1.0

        
On this page

Search results