Overview

Namespaces

  • Alpha
    • Controller
      • Front
    • Exception
    • Model
      • Type
    • Task
    • Util
      • Backup
      • Cache
      • Code
        • Highlight
        • Metric
      • Config
      • Convertor
      • Email
      • Extension
      • Feed
      • File
      • Graph
      • Helper
      • Http
        • Filter
        • Session
      • Image
      • Logging
      • Search
      • Security
    • View
      • Renderer
        • Html
        • Json
      • Widget

Classes

  • ActionLog
  • ActiveRecord
  • ActiveRecordProviderFactory
  • ActiveRecordProviderMySQL
  • ActiveRecordProviderSQLite
  • Article
  • ArticleComment
  • ArticleVote
  • BadRequest
  • BlacklistedClient
  • BlacklistedIP
  • Person
  • Rights
  • Tag

Interfaces

  • ActiveRecordProviderInterface
  • Overview
  • Namespace
  • Class
  • Tree

Class ActiveRecord

Base active record class definition providing database storage via the configured provider.

Direct known subclasses

Alpha\Model\ActionLog, Alpha\Model\Article, Alpha\Model\Type\DEnum, Alpha\Model\Type\DEnumItem, Alpha\Model\Type\RelationLookup, Alpha\Model\Type\Sequence, Alpha\Model\ArticleComment, Alpha\Model\ArticleVote, Alpha\Model\BadRequest, Alpha\Model\BlacklistedClient, Alpha\Model\BlacklistedIP, Alpha\Model\Person, Alpha\Model\Rights, Alpha\Model\Tag
Abstract
Namespace: Alpha\Model
Copyright: Copyright (c) 2015, John Collins (founder of Alpha Framework). All rights reserved. <pre> 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. </pre>
License: The BSD License
Author: John Collins <dev@alphaframework.org>
Since: 1.0
Located at Model/ActiveRecord.php
Methods summary
public
# __construct( )

The constructor which sets up some housekeeping attributes.

The constructor which sets up some housekeeping attributes.

Since

1.0
public static
# disconnect( )

Disconnects the current database connection if one exists.

Disconnects the current database connection if one exists.

Since

1.0
public array
# query( string $sqlQuery )

Returns a 2d array, where each element in the array is another array representing a database row.

Returns a 2d array, where each element in the array is another array representing a database row.

Parameters

$sqlQuery
string $sqlQuery

Returns

array
array

Throws

Alpha\Exception\CustomQueryException
Alpha\Exception\CustomQueryException

Since

1.1
public
# load( integer $OID, integer $version = 0 )

Populates the child object with the properties retrived from the database for the object $OID.

Populates the child object with the properties retrived from the database for the object $OID.

Parameters

$OID
int $OID The object ID of the business object to load.
$version
int $version Optionaly, provide the version to load that version from the [tablename]_history table.

Throws

Alpha\Exception\RecordNotFoundException
Alpha\Exception\RecordNotFoundException

Since

1.0
public array
# loadAllOldVersions( integer $OID )

Load all old versions (if any) of this record from the [tablename]_history table.

Load all old versions (if any) of this record from the [tablename]_history table.

Parameters

$OID
int $OID The object ID of the record to load.

Returns

array
An array containing objects of this type of record object, order by version.

Throws

Alpha\Exception\RecordFoundException
Alpha\Exception\RecordFoundException

Since

2.0
public
# loadByAttribute( string $attribute, string $value, boolean $ignoreClassType = false, array $loadAttributes = array() )

Populates the child object from the database table by the given attribute value.

Populates the child object from the database table by the given attribute value.

Parameters

$attribute
string $atribute The name of the attribute to load the object by.
$value
string $value The value of the attribute to load the object by.
$ignoreClassType
bool $ignoreClassType Default is false, set to true if you want to load from overloaded tables and ignore the class type
$loadAttributes
array $loadAttributes The attributes to load from the database to this object (leave blank to load all attributes)

Throws

Alpha\Exception\RecordNotFoundException
Alpha\Exception\RecordNotFoundException

Since

1.0
public array
# loadAll( integer $start = 0, integer $limit = 0, string $orderBy = 'OID', string $order = 'ASC', boolean $ignoreClassType = false )

Loads all of the objects of this class into an array which is returned.

Loads all of the objects of this class into an array which is returned.

Parameters

$start
int $start The start of the SQL LIMIT clause, useful for pagination.
$limit
int $limit The amount (limit) of objects to load, useful for pagination.
$orderBy
string $orderBy The name of the field to sort the objects by.
$order
string $order The order to sort the objects by.
$ignoreClassType
bool $ignoreClassType Default is false, set to true if you want to load from overloaded tables and ignore the class type

Returns

array
An array containing objects of this type of business object.

Throws

Alpha\Exception\RecordNotFoundException
Alpha\Exception\RecordNotFoundException

Since

1.0
public array
# loadAllByAttribute( string $attribute, string $value, integer $start = 0, integer $limit = 0, string $orderBy = 'OID', string $order = 'ASC', boolean $ignoreClassType = false, array $constructorArgs = array() )

Loads all of the objects of this class by the specified attribute into an array which is returned.

Loads all of the objects of this class by the specified attribute into an array which is returned.

Parameters

$attribute
string $atribute The attribute to load the objects by.
$value
string $value The value of the attribute to load the objects by.
$start
int $start The start of the SQL LIMIT clause, useful for pagination.
$limit
int $limit The amount (limit) of objects to load, useful for pagination.
$orderBy
string $orderBy The name of the field to sort the objects by.
$order
string $order The order to sort the objects by.
$ignoreClassType
bool $ignoreClassType Default is false, set to true if you want to load from overloaded tables and ignore the class type.
$constructorArgs
array $constructorArgs An optional array of contructor arguements to pass to the BOs that will be generated and returned. Supports a maximum of 5 arguements.

Returns

array
An array containing objects of this type of business object.

Throws

Alpha\Exception\RecordNotFoundException
Alpha\Exception\RecordNotFoundException
Alpha\Exception\IllegalArguementException
Alpha\Exception\IllegalArguementException

Since

1.0
public array
# loadAllByAttributes( array $attributes = array(), array $values = array(), integer $start = 0, integer $limit = 0, string $orderBy = 'OID', string $order = 'ASC', boolean $ignoreClassType = false )

Loads all of the objects of this class by the specified attributes into an array which is returned.

Loads all of the objects of this class by the specified attributes into an array which is returned.

Parameters

$attributes
array $atributes The attributes to load the objects by.
$values
array $values The values of the attributes to load the objects by.
$start
int $start The start of the SQL LIMIT clause, useful for pagination.
$limit
int $limit The amount (limit) of objects to load, useful for pagination.
$orderBy
string $orderBy The name of the field to sort the objects by.
$order
string $order The order to sort the objects by.
$ignoreClassType
bool $ignoreClassType Default is false, set to true if you want to load from overloaded tables and ignore the class type

Returns

array
An array containing objects of this type of business object.

Throws

Alpha\Exception\RecordNotFoundException
Alpha\Exception\RecordNotFoundException
Alpha\Exception\IllegalArguementException
Alpha\Exception\IllegalArguementException

Since

1.0
public array
# loadAllByDayUpdated( string $date, integer $start = 0, integer $limit = 0, string $orderBy = 'OID', string $order = 'ASC', boolean $ignoreClassType = false )

Loads all of the objects of this class that where updated (updated_ts value) on the date indicated.

Loads all of the objects of this class that where updated (updated_ts value) on the date indicated.

Parameters

$date
string $date The date for which to load the objects updated on, in the format 'YYYY-MM-DD'.
$start
int $start The start of the SQL LIMIT clause, useful for pagination.
$limit
int $limit The amount (limit) of objects to load, useful for pagination.
$orderBy
string $orderBy The name of the field to sort the objects by.
$order
string $order The order to sort the objects by.
$ignoreClassType
bool $ignoreClassType Default is false, set to true if you want to load from overloaded tables and ignore the class type

Returns

array
An array containing objects of this type of business object.

Throws

Alpha\Exception\RecordNotFoundException
Alpha\Exception\RecordNotFoundException

Since

1.0
public array
# loadAllFieldValuesByAttribute( string $attribute, string $value, string $returnAttribute, string $order = 'ASC', boolean $ignoreClassType = false )

Loads all of the specified attribute values of this class by the specified attribute into an array which is returned.

Loads all of the specified attribute values of this class by the specified attribute into an array which is returned.

Parameters

$attribute
string $attribute The attribute name to load the field values by.
$value
string $value The value of the attribute to load the field values by.
$returnAttribute
string $returnAttribute The name of the attribute to return.
$order
string $order The order to sort the BOs by.
$ignoreClassType
bool $ignoreClassType Default is false, set to true if you want to load from overloaded tables and ignore the class type.

Returns

array
An array of field values.

Throws

Alpha\Exception\RecordNotFoundException
Alpha\Exception\RecordNotFoundException

Since

1.0
public
# save( )

Saves the object. If $this->OID is empty or null it will INSERT, otherwise UPDATE.

Saves the object. If $this->OID is empty or null it will INSERT, otherwise UPDATE.

Throws

Alpha\Exception\FailedSaveException
Alpha\Exception\FailedSaveException
Alpha\Exception\LockingException
Alpha\Exception\LockingException
Alpha\Exception\ValidationException
Alpha\Exception\ValidationException

Since

1.0
public
# saveAttribute( string $attribute, mixed $value )

Saves the field specified with the value supplied. Only works for persistent BOs. Note that no Alpha type validation is performed with this method!

Saves the field specified with the value supplied. Only works for persistent BOs. Note that no Alpha type validation is performed with this method!

Parameters

$attribute
string $attribute The name of the attribute to save.
$value
mixed $value The value of the attribute to save.

Throws

Alpha\Exception\IllegalArguementException
Alpha\Exception\IllegalArguementException
Alpha\Exception\FailedSaveException
Alpha\Exception\FailedSaveException

Since

1.0
public
# saveHistory( )

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

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

Throws

Alpha\Exception\FailedSaveException
FailedSaveException

Since

1.2
protected boolean
# validate( )

Validates the object to be saved.

Validates the object to be saved.

Returns

boolean
bool

Throws

Alpha\Exception\ValidationException
ValidationException

Since

1.0
public
# delete( )

Deletes the current object from the database.

Deletes the current object from the database.

Throws

Alpha\Exception\FailedDeleteException
Alpha\Exception\FailedDeleteException

Since

1.0
public integer
# deleteAllByAttribute( string $attribute, mixed $value )

Delete all object instances from the database by the specified attribute matching the value provided.

Delete all object instances from the database by the specified attribute matching the value provided.

Parameters

$attribute
string $attribute The name of the field to delete the objects by.
$value
mixed $value The value of the field to delete the objects by.

Returns

integer
The number of rows deleted.

Throws

Alpha\Exception\FailedDeleteException
Alpha\Exception\FailedDeleteException

Since

1.0
public integer
# getVersion( )

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

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

Returns

integer
int

Throws

Alpha\Exception\RecordNotFoundException
Alpha\Exception\RecordNotFoundException

Since

1.0
public
# makeTable( )

Builds a new database table for the BO class.

Builds a new database table for the BO class.

Throws

Alpha\Exception\AlphaException
Alpha\Exception\AlphaException

Since

1.0
public
# makeHistoryTable( )

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

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

Throws

Alpha\Exception\AlphaException
Alpha\Exception\AlphaException

Since

1.2
public
# rebuildTable( )

Re-builds the table if the model requirements have changed. All data is lost!

Re-builds the table if the model requirements have changed. All data is lost!

Throws

Alpha\Exception\AlphaException
Alpha\Exception\AlphaException

Since

1.0
public
# dropTable( string $tableName = null )

Drops the table if the model requirements have changed. All data is lost!

Drops the table if the model requirements have changed. All data is lost!

Parameters

$tableName
string $tableName Optional table name, leave blank for the defined table for this class to be dropped

Throws

Alpha\Exception\AlphaException
Alpha\Exception\AlphaException

Since

1.0
public
# addProperty( string $propName )

Adds in a new class property without loosing existing data (does an ALTER TABLE query on the database).

Adds in a new class property without loosing existing data (does an ALTER TABLE query on the database).

Parameters

$propName
string $propName The name of the new field to add to the database table.

Throws

Alpha\Exception\AlphaException
Alpha\Exception\AlphaException

Since

1.0
public
# populateFromArray( array $hashArray )

Populates the current business object from the provided hash array.

Populates the current business object from the provided hash array.

Parameters

$hashArray
array $hashArray

Since

1.2.1
public integer
# getMAX( )

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

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

Returns

integer
The maximum OID value in the class table.

Throws

Alpha\Exception\AlphaException
Alpha\Exception\AlphaException

Since

1.0
public integer
# getCount( array $attributes = array(), array $values = array() )

Gets the count from the database for the amount of objects of this class.

Gets the count from the database for the amount of objects of this class.

Parameters

$attributes
array $atributes The attributes to count the objects by (optional).
$values
array $values The values of the attributes to count the objects by (optional).

Returns

integer
int

Throws

Alpha\Exception\AlphaException
Alpha\Exception\AlphaException
Alpha\Exception\IllegalArguementException
Alpha\Exception\IllegalArguementException

Since

1.0
public integer
# 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.

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.

Returns

integer
int

Throws

Alpha\Exception\AlphaException
Alpha\Exception\AlphaException

Since

1.2
public integer
# getID( )

Gets the OID for the object in zero-padded format (same as getOID()). This version is designed to be overridden in case you want to do something different with the ID of your objects outside of the standard 11 digit OID sequence used internally in Alpha.

Gets the OID for the object in zero-padded format (same as getOID()). This version is designed to be overridden in case you want to do something different with the ID of your objects outside of the standard 11 digit OID sequence used internally in Alpha.

Returns

integer
11 digit zero-padded OID value.

Since

1.0
final public integer
# getOID( )

Gets the OID for the object in zero-padded format (same as getID()). This version is final so cannot be overridden.

Gets the OID for the object in zero-padded format (same as getID()). This version is final so cannot be overridden.

Returns

integer
11 digit zero-padded OID value.

Since

1.0
public Alpha\Model\Type\Integer
# getVersionNumber( )

Method for getting version number of the object.

Method for getting version number of the object.

Returns

Alpha\Model\Type\Integer
The object version number.

Since

1.0
protected
# setEnumOptions( )

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

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

Throws

Alpha\Exception\AlphaException
Alpha\Exception\AlphaException

Since

1.0
public mixed
# get( string $prop, boolean $noChildMethods = false )

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).

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).

Parameters

$prop
string $prop The name of the object property to get.
$noChildMethods
bool $noChildMethods Set to true if you do not want to use getters in the child object, defaults to false.

Returns

mixed
The property value.

Throws

Alpha\Exception\IllegalArguementException
Alpha\Exception\IllegalArguementException
Alpha\Exception\AlphaException
Alpha\Exception\AlphaException

Since

1.0
public
# set( string $prop, mixed $value, boolean $noChildMethods = false )

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).

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).

Parameters

$prop
string $prop The name of the property to set.
$value
mixed $value The value of the property to set.
$noChildMethods
bool $noChildMethods Set to true if you do not want to use setters in the child object, defaults to false.

Throws

Alpha\Exception\AlphaException
Alpha\Exception\AlphaException

Since

1.0
public Alpha\Model\Type\TypeInterface
# getPropObject( string $prop )

Gets the property object rather than the value for complex attributes. Returns false if the property exists but is private.

Gets the property object rather than the value for complex attributes. Returns false if the property exists but is private.

Parameters

$prop
string $prop The name of the property we are getting.

Returns

Alpha\Model\Type\TypeInterface
The complex type object found.

Throws

Alpha\Exception\IllegalArguementException
Alpha\Exception\IllegalArguementException

Since

1.0
public boolean
# checkTableExists( boolean $checkHistoryTable = false )

Checks to see if the table exists in the database for the current business class.

Checks to see if the table exists in the database for the current business class.

Parameters

$checkHistoryTable
bool $checkHistoryTable Set to true if you want to check for the existance of the _history table for this DAO.

Returns

boolean
bool

Throws

Alpha\Exception\AlphaException
Alpha\Exception\AlphaException

Since

1.0
public static boolean
# checkBOTableExists( string $BOClassName, boolean $checkHistoryTable = false )

Static method to check the database and see if the table for the indicated BO class name exists (assumes table name will be $BOClassName less "Object").

Static method to check the database and see if the table for the indicated BO class name exists (assumes table name will be $BOClassName less "Object").

Parameters

$BOClassName
string $BOClassName The name of the business object class we are checking.
$checkHistoryTable
bool $checkHistoryTable Set to true if you want to check for the existance of the _history table for this DAO.

Returns

boolean
bool

Throws

Alpha\Exception\AlphaException
Alpha\Exception\AlphaException

Since

1.0
public boolean
# 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.

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.

Returns

boolean
bool

Throws

Alpha\Exception\AlphaException
Alpha\Exception\AlphaException

Since

1.0
public array
# findMissingFields( )

Returns an array containing any properties on the class which have not been created on the database table yet.

Returns an array containing any properties on the class which have not been created on the database table yet.

Returns

array
An array of missing fields in the database table.

Throws

Alpha\Exception\AlphaException
Alpha\Exception\AlphaException

Since

1.0
public string
# getTableName( )

Getter for the TABLE_NAME, which should be set by a child of this class.

Getter for the TABLE_NAME, which should be set by a child of this class.

Returns

string
The table name in the database.

Throws

Alpha\Exception\AlphaException
Alpha\Exception\AlphaException

Since

1.0
public Alpha\Model\Type\Integer
# getCreatorId( )

Method for getting the OID of the person who created this BO.

Method for getting the OID of the person who created this BO.

Returns

Alpha\Model\Type\Integer
The OID of the creator.

Since

1.0
public Alpha\Model\Type\Integer
# getUpdatorId( )

Method for getting the OID of the person who updated this BO.

Method for getting the OID of the person who updated this BO.

Returns

Alpha\Model\Type\Integer
The OID of the updator.

Since

1.0
public Alpha\Model\Type\Timestamp
# getCreateTS( )

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

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

Returns

Alpha\Model\Type\Timestamp
Alpha\Model\Type\Timestamp

Since

1.0
public Alpha\Model\Type\Timestamp
# getUpdateTS( )

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

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

Returns

Alpha\Model\Type\Timestamp
Alpha\Model\Type\Timestamp

Since

1.0
public
# markTransient( string $attributeName )

Adds the name of the attribute provided to the list of transient (non-saved) attributes for this BO.

Adds the name of the attribute provided to the list of transient (non-saved) attributes for this BO.

Parameters

$attributeName
string $attributeName The name of the attribute to not save.

Since

1.0
public
# markPersistent( string $attributeName )

Removes the name of the attribute provided from the list of transient (non-saved) attributes for this BO, ensuring that it will be saved on the next attempt.

Removes the name of the attribute provided from the list of transient (non-saved) attributes for this BO, ensuring that it will be saved on the next attempt.

Parameters

$attributeName
string $attributeName The name of the attribute to save.

Since

1.0
protected
# markUnique( string $attribute1Name, string $attribute2Name = '', string $attribute3Name = '' )

Adds the name of the attribute(s) provided to the list of unique (constrained) attributes for this BO.

Adds the name of the attribute(s) provided to the list of unique (constrained) attributes for this BO.

Parameters

$attribute1Name
string $attribute1Name The first attribute to mark unique in the database.
$attribute2Name
string $attribute2Name The second attribute to mark unique in the databse (optional, use only for composite keys).
$attribute3Name
string $attribute3Name The third attribute to mark unique in the databse (optional, use only for composite keys).

Since

1.0
public array
# getUniqueAttributes( )

Returns the array of names of unique attributes on this BO.

Returns the array of names of unique attributes on this BO.

Returns

array
array

Since

1.1
public array
# getIndexes( )

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

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

Returns

array
An array of database indexes on this table.

Throws

Alpha\Exception\AlphaException
Alpha\Exception\AlphaException

Since

1.0
public
# createForeignIndex( string $attributeName, string $relatedClass, string $relatedClassAttribute, boolean $indexName = null )

Creates a foreign key constraint (index) in the database on the given attribute.

Creates a foreign key constraint (index) in the database on the given attribute.

Parameters

$attributeName
string $attributeName The name of the attribute to apply the index on.
$relatedClass
string $relatedClass The name of the related class in the format "NameObject".
$relatedClassAttribute
string $relatedClassAttribute The name of the field to relate to on the related class.
$indexName
bool $allowNullValues For foreign key indexes that don't allow null values, set this to false (default is true).

Throws

Alpha\Exception\FailedIndexCreateException
Alpha\Exception\FailedIndexCreateException

Since

1.0
public
# createUniqueIndex( string $attribute1Name, string $attribute2Name = '', string $attribute3Name = '' )

Creates a unique index in the database on the given attribute(s).

Creates a unique index in the database on the given attribute(s).

Parameters

$attribute1Name
string $attribute1Name The first attribute to mark unique in the database.
$attribute2Name
string $attribute2Name The second attribute to mark unique in the databse (optional, use only for composite keys).
$attribute3Name
string $attribute3Name The third attribute to mark unique in the databse (optional, use only for composite keys).

Throws

Alpha\Exception\FailedIndexCreateException
Alpha\Exception\FailedIndexCreateException

Since

1.0
public array
# getDataLabels( )

Gets the data labels array.

Gets the data labels array.

Returns

array
An array of attribute labels.

Since

1.0
public
# setDataLabels( array $labels )

Sets the data labels array.

Sets the data labels array.

Parameters

$labels
array $labels

Throws

Alpha\Exception\IllegalArguementException
Alpha\Exception\IllegalArguementException

Since

1.2
public string
# getDataLabel( mixed $att )

Gets the data label for the given attribute name.

Gets the data label for the given attribute name.

Parameters

$att
$att The attribute name to get the label for.

Returns

string
string

Throws

Alpha\Exception\IllegalArguementException
Alpha\Exception\IllegalArguementException

Since

1.0
public static array
# getBOClassNames( )

Loops over the core and custom BO directories and builds an array of all of the BO class names in the system.

Loops over the core and custom BO directories and builds an array of all of the BO class names in the system.

Returns

array
An array of business object class names.

Since

1.0
public array
# getDefaultAttributes( )

Get the array of default attribute names.

Get the array of default attribute names.

Returns

array
An array of attribute names.

Since

1.0
public array
# getTransientAttributes( )

Get the array of transient attribute names.

Get the array of transient attribute names.

Returns

array
An array of attribute names.

Since

1.0
public array
# getPersistentAttributes( )

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

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

Returns

array
An array of attribute names.

Since

1.0
public
# setOID( integer $OID )

Setter for the Object ID (OID).

Setter for the Object ID (OID).

Parameters

$OID
int $OID The Object ID.

Since

1.0
public boolean
# isTransient( )

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

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

Returns

boolean
bool

Since

1.0
public string
# getLastQuery( )

Get the last database query run on this object.

Get the last database query run on this object.

Returns

string
An SQL query string.

Since

1.0
public
# reload( )

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

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

Throws

Alpha\Exception\AlphaException
Alpha\Exception\AlphaException

Since

1.0
public boolean
# checkRecordExists( integer $OID )

Checks that a record exists for the BO in the database.

Checks that a record exists for the BO in the database.

Parameters

$OID
int $OID The Object ID of the object we want to see whether it exists or not.

Returns

boolean
bool

Throws

Alpha\Exception\AlphaException
Alpha\Exception\AlphaException

Since

1.0
public boolean
# isTableOverloaded( )

Checks to see if the table name matches the classname, and if not if the table name matches the classname name of another BO, i.e. the table is used to store multiple types of BOs.

Checks to see if the table name matches the classname, and if not if the table name matches the classname name of another BO, i.e. the table is used to store multiple types of BOs.

Returns

boolean
bool

Throws

Alpha\Exception\BadBOTableNameException
Alpha\Exception\BadBOTableNameException

Since

1.0
public static
# begin( mixed $BO = null )

Starts a new database transaction.

Starts a new database transaction.

Parameters

$BO
$BO The ActiveRecord instance to pass to the database provider. Leave empty to have a new Person passed.

Throws

Alpha\Exception\AlphaException
Alpha\Exception\AlphaException

Since

1.0
public static
# commit( mixed $BO = null )

Commits the current database transaction.

Commits the current database transaction.

Parameters

$BO
$BO The ActiveRecord instance to pass to the database provider. Leave empty to have a new Person passed.

Throws

Alpha\Exception\FailedSaveException
Alpha\Exception\FailedSaveException

Since

1.0
public static
# rollback( mixed $BO = null )

Aborts the current database transaction.

Aborts the current database transaction.

Parameters

$BO
$BO The ActiveRecord instance to pass to the database provider. Leave empty to have a new Person passed.

Throws

ALpha\Exception\AlphaException
ALpha\Exception\AlphaException

Since

1.0
public static boolean
# isInstalled( )

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

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

Returns

boolean
bool

Since

1.0
public boolean
# isTagged( )

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

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

Returns

boolean
bool

Since

1.0
public array
# getTaggedAttributes( )

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

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

Returns

array
array

Since

1.2.3
public Alpha\Model\ActiveRecord
# cast( string $targetClassName, Alpha\Model\ActiveRecord $originalBO )

Cast a BO to another type of BO. A new BO will be returned with the same OID and version_num as the old BO, so this is NOT a true cast but is a copy. All attribute values will be copied accross.

Cast a BO to another type of BO. A new BO will be returned with the same OID and version_num as the old BO, so this is NOT a true cast but is a copy. All attribute values will be copied accross.

Parameters

$targetClassName
string $targetClassName The fully-qualified name of the target BO class.
$originalBO
Alpha\Model\ActiveRecord $originalBO The original business object.

Returns

Alpha\Model\ActiveRecord
The new business object resulting from the cast.

Since

1.0
public string
# getFriendlyClassName( )

Returns the simple class name, stripped of the namespace.

Returns the simple class name, stripped of the namespace.

Returns

string
string

Since

1.0
public boolean
# hasAttribute( mixed $attribute )

Check to see if an attribute exists on the BO.

Check to see if an attribute exists on the BO.

Parameters

$attribute
$attribute The attribute name.

Returns

boolean
bool

Since

1.0
public
# addToCache( )

Stores the business object to the configured cache instance.

Stores the business object to the configured cache instance.

Since

1.1
public
# removeFromCache( )

Removes the business object from the configured cache instance.

Removes the business object from the configured cache instance.

Since

1.1
public boolean
# loadFromCache( )

Attempts to load the business object from the configured cache instance.

Attempts to load the business object from the configured cache instance.

Returns

boolean
bool

Since

1.1
public
# setLastQuery( string $query )

Sets the last query executed on this business object.

Sets the last query executed on this business object.

Parameters

$query
string $query

Since

1.1
public
# __wakeup( )

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

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

Since

1.2
public
# setMaintainHistory( boolean $maintainHistory )

Sets maintainHistory attribute on this DAO.

Sets maintainHistory attribute on this DAO.

Parameters

$maintainHistory
bool $maintainHistory

Throws

ALpha\Exception\IllegalArguementException
ALpha\Exception\IllegalArguementException

Since

1.2
public boolean
# getMaintainHistory( )

Gets the value of the maintainHistory attribute.

Gets the value of the maintainHistory attribute.

Returns

boolean
bool

Since

1.2
public array
# toArray( )

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

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

Returns

array
array

Since

1.2.4
public static boolean
# checkDatabaseExists( )

Check to see if the configured database exists.

Check to see if the configured database exists.

Returns

boolean
bool

Since

2.0
public static
# createDatabase( )

Creates the configured database.

Creates the configured database.

Throws

Alpha\Exception\AlphaException
Alpha\Exception\AlphaException

Since

2.0
public static
# dropDatabase( )

Drops the configured database.

Drops the configured database.

Throws

Alpha\Exception\AlphaException
Alpha\Exception\AlphaException

Since

2.0
Properties summary
protected integer $OID
#

The object ID.

The object ID.

Since

1.0
protected string $lastQuery
#

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

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

Since

1.0
protected Alpha\Model\Type\Integer $version_num
#

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

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

Since

1.0
protected Alpha\Model\Type\Timestamp $created_ts
#

The timestamp of creation.

The timestamp of creation.

Since

1.0
protected Alpha\Model\Type\Integer $created_by
#

The OID of the person who created this BO.

The OID of the person who created this BO.

Since

1.0
protected Alpha\Model\Type\Timestamp $updated_ts
#

The timestamp of the last update.

The timestamp of the last update.

Since

1.0
protected Alpha\Model\Type\Integer $updated_by
#

The OID of the person who last updated this BO.

The OID of the person who last updated this BO.

Since

1.0
protected array $defaultAttributes array('OID', 'lastQuery', 'version_num', 'dataLabels', 'created_ts', 'created_by', 'updated_ts', 'updated_by', 'defaultAttributes', 'transientAttributes', 'uniqueAttributes', 'TABLE_NAME', 'logger')
#

An array of the names of all of the default attributes of a persistent BO defined in this class.

An array of the names of all of the default attributes of a persistent BO defined in this class.

Since

1.0
protected array $transientAttributes array('lastQuery', 'dataLabels', 'defaultAttributes', 'transientAttributes', 'uniqueAttributes', 'TABLE_NAME', 'logger')
#

An array of the names of all of the transient attributes of a persistent BO which are not saved to the DB.

An array of the names of all of the transient attributes of a persistent BO which are not saved to the DB.

Since

1.0
protected array $uniqueAttributes array()
#

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

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

Since

1.0
protected array $dataLabels array()
#

An array of the data labels used for displaying class attributes.

An array of the data labels used for displaying class attributes.

Since

1.0
Alpha Framework 2.0.4 API Documentation API documentation generated by ApiGen 2.8.0