Starts a new database transaction.
API Tags:
Information Tags:
Throws: | AlphaException |
Since: | 1.0 |
static boolean checkBOTableExists(
string
$BOClassName
)
|
|
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:
string |
$BOClassName: |
The name of the business object class we are checking. |
API Tags:
Information Tags:
Throws: | AlphaException |
Since: | 1.0 |
static boolean checkClassDefExists(
string
$classname
)
|
|
Checks if the definition for the BO class name provided exists on the file system.
Parameters:
string |
$classname: |
The name of the business object class name. |
API Tags:
Information Tags:
Commits the current database transaction.
API Tags:
Information Tags:
Throws: | FailedSaveException |
Since: | 1.0 |
static void disconnect(
)
|
|
Disconnects the current database connection if one exists
API Tags:
Information Tags:
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.
API Tags:
Return: | An array of business object class names. |
Access: | public |
Information Tags:
static mysqli getConnection(
)
|
|
Gets the current connection singleton, or creates a new one if none exists
API Tags:
Deprecated: | |
Access: | public |
Information Tags:
Since: | 1.0 |
Throws: | AlphaException |
static boolean isInstalled(
)
|
|
Static method that tries to determine if the system database has been installed or not.
API Tags:
Information Tags:
static void loadClassDef(
string
$classname
)
|
|
Loads the definition from the file system for the BO class name provided.
Parameters:
string |
$classname: |
The name of the business object class name. |
API Tags:
Information Tags:
Throws: | IllegalArguementException |
Since: | 1.0 |
Aborts the current database transaction.
API Tags:
Information Tags:
Throws: | AlphaException |
Since: | 1.0 |
The constructor which sets up some housekeeping attributes
API Tags:
Information Tags:
Redefined in descendants as:
void addProperty(
string
$propName
)
|
|
Adds in a new class property without loosing existing data (does an ALTER TABLE query on the database).
Parameters:
string |
$propName: |
The name of the new field to add to the database table. |
API Tags:
Information Tags:
Since: | 1.0 |
Throws: | AlphaException |
Stores the business object to the configured cache instance
API Tags:
Information Tags:
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:
string |
$targetClassName: |
The name of the target BO class. |
AlphaDAO |
$originalBO: |
The original business object. |
API Tags:
Return: | The new business object resulting from the cast. |
Access: | public |
Information Tags:
boolean checkRecordExists(
int
$OID
)
|
|
Checks that a record exists for the BO in the database.
Parameters:
int |
$OID: |
The Object ID of the object we want to see whether it exists or not. |
API Tags:
Information Tags:
Since: | 1.0 |
Throws: | AlphaException |
boolean checkTableExists(
)
|
|
Checks to see if the table exists in the database for the current business class.
API Tags:
Information Tags:
Since: | 1.0 |
Throws: | AlphaException |
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.
API Tags:
Information Tags:
Since: | 1.0 |
Throws: | AlphaException |
void createForeignIndex(
string
$attributeName, string
$relatedClass, string
$relatedClassAttribute, bool
$allowNullValues
)
|
|
Creates a foreign key constraint (index) in the database on the given attribute.
Parameters:
string |
$attributeName: |
The name of the attribute to apply the index on. |
string |
$relatedClass: |
The name of the related class in the format "NameObject". |
string |
$relatedClassAttribute: |
The name of the field to relate to on the related class. |
bool |
$allowNullValues: |
For foreign key indexes that don't allow null values, set this to false (default is true). |
API Tags:
Information Tags:
Since: | 1.0 |
Throws: | FailedIndexCreateException |
void createUniqueIndex(
string
$attribute1Name, [string
$attribute2Name = ''], [string
$attribute3Name = '']
)
|
|
Creates a unique index in the database on the given attribute(s).
Parameters:
string |
$attribute1Name: |
The first attribute to mark unique in the database. |
string |
$attribute2Name: |
The second attribute to mark unique in the databse (optional, use only for composite keys). |
string |
$attribute3Name: |
The third attribute to mark unique in the databse (optional, use only for composite keys). |
API Tags:
Information Tags:
Since: | 1.0 |
Throws: | FailedIndexCreateException |
Deletes the current object from the database.
API Tags:
Information Tags:
Since: | 1.0 |
Throws: | FailedDeleteException |
integer deleteAllByAttribute(
string
$attribute, mixed
$value
)
|
|
Delete all object instances from the database by the specified attribute matching the value provided.
Parameters:
string |
$attribute: |
The name of the field to delete the objects by. |
mixed |
$value: |
The value of the field to delete the objects by. |
API Tags:
Return: | The number of rows deleted. |
Access: | public |
Information Tags:
Since: | 1.0 |
Throws: | FailedDeleteException |
void dropTable(
[string
$tableName = null]
)
|
|
Drops the table if the model requirements have changed. All data is lost!
Parameters:
string |
$tableName: |
Optional table name, leave blank for the defined table for this class to be dropped |
API Tags:
Information Tags:
Since: | 1.0 |
Throws: | AlphaException |
array findMissingFields(
)
|
|
Returns an array containing any properties on the class which have not been created on the database table yet.
API Tags:
Return: | An array of missing fields in the database table. |
Access: | public |
Information Tags:
Since: | 1.0 |
Throws: | AlphaException |
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).
Parameters:
string |
$prop: |
The name of the object property to get. |
boolean |
$noChildMethods: |
Set to true if you do not want to use getters in the child object, defaults to false. |
API Tags:
Return: | The property value. |
Access: | public |
Information Tags:
Throws: | IllegalArguementException |
Throws: | AlphaException |
Since: | 1.0 |
integer getCount(
[
$attributes = array()], [array
$values = array()], array
$atributes
)
|
|
Gets the count from the database for the amount of objects of this class.
Parameters:
array |
$atributes: |
The attributes to count the objects by (optional). |
array |
$values: |
The values of the attributes to count the objects by (optional). |
|
$attributes: |
|
API Tags:
Information Tags:
Since: | 1.0 |
Throws: | AlphaException |
Method for getting the date/time of when the BO was created.
API Tags:
Information Tags:
Method for getting the OID of the person who created this BO.
API Tags:
Return: | The OID of the creator. |
Access: | public |
Information Tags:
string getDataLabel(
$att
$att
)
|
|
Gets the data label for the given attribute name.
Parameters:
$att |
$att: |
The attribute name to get the label for. |
API Tags:
Information Tags:
Since: | 1.0 |
Throws: | IllegalArguementException |
Gets the data labels array.
API Tags:
Return: | An array of attribute labels. |
Access: | public |
Information Tags:
array getDefaultAttributes(
)
|
|
Get the array of default attribute names.
API Tags:
Return: | An array of attribute names. |
Access: | public |
Information Tags:
string getFriendlyClassName(
)
|
|
Converts "BusinessObject" to "Business" and returns.
API Tags:
Information Tags:
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.
API Tags:
Return: | 11 digit zero-padded OID value. |
Access: | public |
Information Tags:
Gets an array of all of the names of the active database indexes for this class.
API Tags:
Return: | An array of database indexes on this table. |
Access: | public |
Information Tags:
Since: | 1.0 |
Throws: | AlphaException |
Get the last database query run on this object.
API Tags:
Return: | An SQL query string. |
Access: | public |
Information Tags:
Gets the maximum OID value from the database for this class type.
API Tags:
Return: | The maximum OID value in the class table. |
Access: | public |
Information Tags:
Since: | 1.0 |
Throws: | AlphaException |
Gets the OID for the object in zero-padded format (same as getID()). This version is final so cannot be overridden.
API Tags:
Return: | 11 digit zero-padded OID value. |
Access: | public |
Information Tags:
array getPersistentAttributes(
)
|
|
Get the array of persistent attribute names, i.e. those that are saved in the database.
API Tags:
Return: | An array of attribute names. |
Access: | public |
Information Tags:
Gets the property object rather than the value for complex attributes. Returns false if the property exists but is private.
Parameters:
string |
$prop: |
The name of the property we are getting. |
API Tags:
Return: | The complex type object found. |
Access: | public |
Information Tags:
Since: | 1.0 |
Throws: | IllegalArguementException |
Getter for the TABLE_NAME, which should be set by a child of this class.
API Tags:
Return: | The table name in the database. |
Access: | public |
Information Tags:
Since: | 1.0 |
Throws: | AlphaException |
Redefined in descendants as:
-
RelationLookup::getTableName()
: Custom getter for the TABLE_NAME, which can't be static in this class due to the lookup tablenames being different each time.
array getTransientAttributes(
)
|
|
Get the array of transient attribute names.
API Tags:
Return: | An array of attribute names. |
Access: | public |
Information Tags:
array getUniqueAttributes(
)
|
|
Returns the array of names of unique attributes on this BO
API Tags:
Information Tags:
Method for getting the date/time of when the BO was last updated.
API Tags:
Information Tags:
Method for getting the OID of the person who updated this BO.
API Tags:
Return: | The OID of the updator. |
Access: | public |
Information Tags:
Gets the version_num of the object from the database (returns 0 if the BO is not saved yet).
API Tags:
Information Tags:
Since: | 1.0 |
Throws: | BONotFoundException |
Method for getting version number of the object.
API Tags:
Return: | The object version number. |
Access: | public |
Information Tags:
boolean hasAttribute(
$attribute
$attribute
)
|
|
Check to see if an attribute exists on the BO.
Parameters:
$attribute |
$attribute: |
The attribute name. |
API Tags:
Information Tags:
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 BO, i.e. the table is used to store multiple types of BOs.
API Tags:
Information Tags:
Since: | 1.0 |
Throws: | BadBOTableNameException |
Returns true if the BO has a Relation property called tags, false otherwise.
API Tags:
Information Tags:
Inspector to see if the business object is transient (not presently stored in the database).
API Tags:
Information Tags:
void load(
integer
$OID
)
|
|
Populates the child object with the properties retrived from the database for the object $OID.
Parameters:
integer |
$OID: |
The object ID of the business object to load. |
API Tags:
Information Tags:
Since: | 1.0 |
Throws: | BONotFoundException |
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.
Parameters:
integer |
$start: |
The start of the SQL LIMIT clause, useful for pagination. |
integer |
$limit: |
The amount (limit) of objects to load, useful for pagination. |
string |
$orderBy: |
The name of the field to sort the objects by. |
string |
$order: |
The order to sort the objects by. |
boolean |
$ignoreClassType: |
Default is false, set to true if you want to load from overloaded tables and ignore the class type |
API Tags:
Return: | An array containing objects of this type of business object. |
Access: | public |
Information Tags:
Since: | 1.0 |
Throws: | BONotFoundException |
array loadAllByAttribute(
$attribute, string
$value, [integer
$start = 0], [integer
$limit = 0], [string
$orderBy = "OID"], [string
$order = "ASC"], [boolean
$ignoreClassType = false], [array
$constructorArgs = array()], string
$atribute
)
|
|
Loads all of the objects of this class by the specified attribute into an array which is returned.
Parameters:
string |
$atribute: |
The attribute to load the objects by. |
string |
$value: |
The value of the attribute to load the objects by. |
integer |
$start: |
The start of the SQL LIMIT clause, useful for pagination. |
integer |
$limit: |
The amount (limit) of objects to load, useful for pagination. |
string |
$orderBy: |
The name of the field to sort the objects by. |
string |
$order: |
The order to sort the objects by. |
boolean |
$ignoreClassType: |
Default is false, set to true if you want to load from overloaded tables and ignore the class type. |
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. |
|
$attribute: |
|
API Tags:
Return: | An array containing objects of this type of business object. |
Access: | public |
Information Tags:
Throws: | BONotFoundException |
Throws: | IllegalArguementException |
Since: | 1.0 |
Redefined in descendants as:
array loadAllByAttributes(
[
$attributes = array()], [array
$values = array()], [integer
$start = 0], [integer
$limit = 0], [string
$orderBy = 'OID'], [string
$order = 'ASC'], [boolean
$ignoreClassType = false], array
$atributes
)
|
|
Loads all of the objects of this class by the specified attributes into an array which is returned.
Parameters:
array |
$atributes: |
The attributes to load the objects by. |
array |
$values: |
The values of the attributes to load the objects by. |
integer |
$start: |
The start of the SQL LIMIT clause, useful for pagination. |
integer |
$limit: |
The amount (limit) of objects to load, useful for pagination. |
string |
$orderBy: |
The name of the field to sort the objects by. |
string |
$order: |
The order to sort the objects by. |
boolean |
$ignoreClassType: |
Default is false, set to true if you want to load from overloaded tables and ignore the class type |
|
$attributes: |
|
API Tags:
Return: | An array containing objects of this type of business object. |
Access: | public |
Information Tags:
Throws: | BONotFoundException |
Throws: | IllegalArguementException |
Since: | 1.0 |
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.
Parameters:
string |
$date: |
The date for which to load the objects updated on, in the format 'YYYY-MM-DD'. |
integer |
$start: |
The start of the SQL LIMIT clause, useful for pagination. |
integer |
$limit: |
The amount (limit) of objects to load, useful for pagination. |
string |
$orderBy: |
The name of the field to sort the objects by. |
string |
$order: |
The order to sort the objects by. |
boolean |
$ignoreClassType: |
Default is false, set to true if you want to load from overloaded tables and ignore the class type |
API Tags:
Return: | An array containing objects of this type of business object. |
Access: | public |
Information Tags:
Since: | 1.0 |
Throws: | BONotFoundException |
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.
Parameters:
string |
$attribute: |
The attribute name to load the field values by. |
string |
$value: |
The value of the attribute to load the field values by. |
string |
$returnAttribute: |
The name of the attribute to return. |
string |
$order: |
The order to sort the BOs by. |
boolean |
$ignoreClassType: |
Default is false, set to true if you want to load from overloaded tables and ignore the class type. |
API Tags:
Return: | An array of field values. |
Access: | public |
Information Tags:
Since: | 1.0 |
Throws: | BONotFoundException |
void loadByAttribute(
$attribute, string
$value, [boolean
$ignoreClassType = false], [array
$loadAttributes = array()], string
$atribute
)
|
|
Populates the child object from the database table by the given attribute value.
Parameters:
string |
$atribute: |
The name of the attribute to load the object by. |
string |
$value: |
The value of the attribute to load the object by. |
boolean |
$ignoreClassType: |
Default is false, set to true if you want to load from overloaded tables and ignore the class type |
array |
$loadAttributes: |
The attributes to load from the database to this object (leave blank to load all attributes) |
|
$attribute: |
|
API Tags:
Information Tags:
Since: | 1.0 |
Throws: | BONotFoundException |
Attempts to load the business object from the configured cache instance
API Tags:
Information Tags:
Builds a new database table for the BO class.
API Tags:
Information Tags:
Since: | 1.0 |
Throws: | AlphaException |
void 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.
Parameters:
string |
$attributeName: |
The name of the attribute to save. |
API Tags:
Information Tags:
void markTransient(
string
$attributeName
)
|
|
Adds the name of the attribute provided to the list of transient (non-saved) attributes for this BO.
Parameters:
string |
$attributeName: |
The name of the attribute to not save. |
API Tags:
Information Tags:
void 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.
Parameters:
string |
$attribute1Name: |
The first attribute to mark unique in the database. |
string |
$attribute2Name: |
The second attribute to mark unique in the databse (optional, use only for composite keys). |
string |
$attribute3Name: |
The third attribute to mark unique in the databse (optional, use only for composite keys). |
API Tags:
Information Tags:
void populateFromPost(
[boolean
$filterAll = false]
)
|
|
Populates the current business object from global POST data.
Parameters:
boolean |
$filterAll: |
Defaults to false, set to true if you want to strictly filter all POSTed user input using InputFilter::encode. |
API Tags:
Information Tags:
array query(
string
$sqlQuery
)
|
|
Returns a 2d array, where each element in the array is another array representing a database row.
Parameters:
API Tags:
Information Tags:
Since: | 1.1 |
Throws: | CustomQueryException |
Re-builds the table if the model requirements have changed. All data is lost!
API Tags:
Information Tags:
Since: | 1.0 |
Throws: | AlphaException |
Reloads the object from the database, overwritting any attribute values in memory.
API Tags:
Information Tags:
Since: | 1.0 |
Throws: | AlphaException |
Removes the business object from the configured cache instance
API Tags:
Information Tags:
Saves the object. If $this->OID is empty or null it will INSERT, otherwise UPDATE.
API Tags:
Information Tags:
Throws: | FailedSaveException |
Since: | 1.0 |
Throws: | LockingException |
Throws: | ValidationException |
void 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!
Parameters:
string |
$attribute: |
The name of the attribute to save. |
mixed |
$value: |
The value of the attribute to save. |
API Tags:
Information Tags:
Throws: | IllegalArguementException |
Throws: | FailedSaveException |
Since: | 1.0 |
void 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).
Parameters:
string |
$prop: |
The name of the property to set. |
mixed |
$value: |
The value of the property to set. |
boolean |
$noChildMethods: |
Set to true if you do not want to use setters in the child object, defaults to false. |
API Tags:
Information Tags:
Since: | 1.0 |
Throws: | AlphaException |
Populate all of the enum options for this object from the database.
API Tags:
Information Tags:
Since: | 1.0 |
Throws: | AlphaException |
void setLastQuery(
string
$query
)
|
|
Sets the last query executed on this business object
Parameters:
API Tags:
Information Tags:
void setOID(
integer
$OID
)
|
|
Setter for the Object ID (OID)
Parameters:
integer |
$OID: |
The Object ID. |
API Tags:
Information Tags:
Validates the object to be saved.
API Tags:
Information Tags:
Since: | 1.0 |
Throws: | ValidationException |