ActiveRecordProviderMySQL
in package
implements
ActiveRecordProviderInterface
MySQL active record provider (uses the MySQLi native API in PHP).
Tags
Table of Contents
Interfaces
- ActiveRecordProviderInterface
- An interface that defines all of the active record methods that should be included in a provider that implements this interface.
Properties
- $connection : Mysqli
- Datebase connection.
- $logger : Logger
- Trace logger.
- $record : ActiveRecord
- The business object that we are mapping back to.
Methods
- __construct() : mixed
- The constructor.
- addProperty() : void
- (non-PHPdoc).
- backupDatabase() : void
- (non-PHPdoc).
- begin() : void
- (non-PHPdoc).
- checkDatabaseExists() : bool
- (non-PHPdoc).
- checkRecordExists() : bool
- (non-PHPdoc).
- checkRecordTableExists() : bool
- (non-PHPdoc).
- checkTableExists() : bool
- (non-PHPdoc).
- checkTableNeedsUpdate() : bool
- (non-PHPdoc).
- commit() : void
- (non-PHPdoc).
- createDatabase() : void
- (non-PHPdoc).
- createForeignIndex() : void
- (non-PHPdoc).
- createUniqueIndex() : void
- (non-PHPdoc).
- delete() : void
- (non-PHPdoc).
- disconnect() : void
- (non-PHPdoc).
- dropDatabase() : void
- (non-PHPdoc).
- dropTable() : void
- (non-PHPdoc).
- findMissingFields() : array<string|int, mixed>
- (non-PHPdoc).
- getConnection() : Mysqli
- (non-PHPdoc).
- getCount() : int
- (non-PHPdoc).
- getHistoryCount() : int
- (non-PHPdoc).
- getIndexes() : array<string|int, mixed>
- (non-PHPdoc).
- getLastDatabaseError() : string
- (non-PHPdoc).
- getMAX() : int
- (non-PHPdoc).
- getVersion() : int
- (non-PHPdoc).
- isTableOverloaded() : bool
- (non-PHPdoc).
- load() : void
- (non-PHPdoc).
- loadAll() : array<string|int, mixed>
- (non-PHPdoc).
- loadAllByAttribute() : array<string|int, mixed>
- (non-PHPdoc).
- loadAllByAttributes() : array<string|int, mixed>
- (non-PHPdoc).
- loadAllByDayUpdated() : array<string|int, mixed>
- (non-PHPdoc).
- loadAllFieldValuesByAttribute() : array<string|int, mixed>
- (non-PHPdoc).
- loadAllOldVersions() : array<string|int, mixed>
- (non-PHPdoc).
- loadByAttribute() : void
- (non-PHPdoc).
- makeHistoryTable() : void
- (non-PHPdoc).
- makeTable() : void
- (non-PHPdoc).
- query() : array<string|int, mixed>
- (non-PHPdoc).
- rebuildTable() : void
- (non-PHPdoc).
- reload() : void
- (non-PHPdoc).
- rollback() : void
- (non-PHPdoc).
- save() : void
- (non-PHPdoc).
- saveAttribute() : void
- (non-PHPdoc).
- saveHistory() : void
- (non-PHPdoc).
- setEnumOptions() : void
- (non-PHPdoc).
- setRecord() : void
- (non-PHPdoc).
- bindParams() : mysqli_stmt
- Dynamically binds all of the attributes for the current Record to the supplied prepared statement parameters. If arrays of attribute names and values are provided, only those will be bound to the supplied statement.
- bindResult() : array<string|int, mixed>
- Dynamically binds the result of the supplied prepared statement to a 2d array, where each element in the array is another array representing a database row.
- checkIndexes() : void
- Checks to see if all of the indexes are in place for the record's table, creates those that are missing.
- findOffendingValue() : string
- Parses a MySQL error for the value that violated a unique constraint.
Properties
$connection
Datebase connection.
private
static Mysqli
$connection
Tags
$logger
Trace logger.
private
static Logger
$logger
= null
Tags
$record
The business object that we are mapping back to.
private
ActiveRecord
$record
Tags
Methods
__construct()
The constructor.
public
__construct() : mixed
Tags
addProperty()
(non-PHPdoc).
public
addProperty(mixed $propName) : void
Parameters
- $propName : mixed
-
The name of the new field to add to the database table.
Tags
backupDatabase()
(non-PHPdoc).
public
static backupDatabase(mixed $targetFile) : void
Parameters
- $targetFile : mixed
Tags
begin()
(non-PHPdoc).
public
static begin() : void
Tags
checkDatabaseExists()
(non-PHPdoc).
public
static checkDatabaseExists() : bool
Tags
Return values
boolcheckRecordExists()
(non-PHPdoc).
public
checkRecordExists(mixed $ID) : bool
Parameters
- $ID : mixed
-
The Object ID of the object we want to see whether it exists or not.
Tags
Return values
boolcheckRecordTableExists()
(non-PHPdoc).
public
static checkRecordTableExists(mixed $RecordClassName[, mixed $checkHistoryTable = false ]) : bool
Parameters
- $RecordClassName : mixed
-
The name of the business object class we are checking.
- $checkHistoryTable : mixed = false
-
Set to true if you want to check for the existance of the _history table for this DAO.
Tags
Return values
boolcheckTableExists()
(non-PHPdoc).
public
checkTableExists([mixed $checkHistoryTable = false ]) : bool
Parameters
- $checkHistoryTable : mixed = false
-
Set to true if you want to check for the existance of the _history table for this DAO.
Tags
Return values
boolcheckTableNeedsUpdate()
(non-PHPdoc).
public
checkTableNeedsUpdate() : bool
Tags
Return values
boolcommit()
(non-PHPdoc).
public
static commit() : void
Tags
createDatabase()
(non-PHPdoc).
public
static createDatabase() : void
Tags
createForeignIndex()
(non-PHPdoc).
public
createForeignIndex(mixed $attributeName, mixed $relatedClass, mixed $relatedClassAttribute[, mixed $indexName = null ]) : void
Parameters
- $attributeName : mixed
-
The name of the attribute to apply the index on.
- $relatedClass : mixed
-
The fully-qualified name of the related class.
- $relatedClassAttribute : mixed
-
The name of the field to relate to on the related class.
- $indexName : mixed = null
-
The optional name for the index, will calculate if not provided.
Tags
createUniqueIndex()
(non-PHPdoc).
public
createUniqueIndex(mixed $attribute1Name[, mixed $attribute2Name = '' ][, mixed $attribute3Name = '' ]) : void
Parameters
- $attribute1Name : mixed
-
The first attribute to mark unique in the database.
- $attribute2Name : mixed = ''
-
The second attribute to mark unique in the databse (optional, use only for composite keys).
- $attribute3Name : mixed = ''
-
The third attribute to mark unique in the databse (optional, use only for composite keys).
Tags
delete()
(non-PHPdoc).
public
delete() : void
Tags
disconnect()
(non-PHPdoc).
public
static disconnect() : void
Tags
dropDatabase()
(non-PHPdoc).
public
static dropDatabase() : void
Tags
dropTable()
(non-PHPdoc).
public
dropTable([mixed $tableName = null ]) : void
Parameters
- $tableName : mixed = null
-
Optional table name, leave blank for the defined table for this class to be dropped
Tags
findMissingFields()
(non-PHPdoc).
public
findMissingFields() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>getConnection()
(non-PHPdoc).
public
static getConnection() : Mysqli
Tags
Return values
MysqligetCount()
(non-PHPdoc).
public
getCount([mixed $attributes = array() ][, mixed $values = array() ]) : int
Parameters
- $attributes : mixed = array()
-
The attributes to count the objects by (optional).
- $values : mixed = array()
-
The values of the attributes to count the objects by (optional).
Tags
Return values
intgetHistoryCount()
(non-PHPdoc).
public
getHistoryCount() : int
Tags
Return values
intgetIndexes()
(non-PHPdoc).
public
getIndexes() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>getLastDatabaseError()
(non-PHPdoc).
public
static getLastDatabaseError() : string
Tags
Return values
stringgetMAX()
(non-PHPdoc).
public
getMAX() : int
Tags
Return values
intgetVersion()
(non-PHPdoc).
public
getVersion() : int
Tags
Return values
intisTableOverloaded()
(non-PHPdoc).
public
isTableOverloaded() : bool
Tags
Return values
boolload()
(non-PHPdoc).
public
load(mixed $ID[, mixed $version = 0 ]) : void
Parameters
- $ID : mixed
-
The object ID of the record to load.
- $version : mixed = 0
-
Optionaly, provide the version to load that version from the [tablename]_history table.
Tags
loadAll()
(non-PHPdoc).
public
loadAll([mixed $start = 0 ][, mixed $limit = 0 ][, mixed $orderBy = 'ID' ][, mixed $order = 'ASC' ][, mixed $ignoreClassType = false ]) : array<string|int, mixed>
Parameters
- $start : mixed = 0
-
The start of the SQL LIMIT clause, useful for pagination.
- $limit : mixed = 0
-
The amount (limit) of records to load, useful for pagination.
- $orderBy : mixed = 'ID'
-
The name of the field to sort the records by.
- $order : mixed = 'ASC'
-
The order to sort the records by.
- $ignoreClassType : mixed = false
-
Default is false, set to true if you want to load from overloaded tables and ignore the class type
Tags
Return values
array<string|int, mixed>loadAllByAttribute()
(non-PHPdoc).
public
loadAllByAttribute(mixed $attribute, mixed $value[, mixed $start = 0 ][, mixed $limit = 0 ][, mixed $orderBy = 'ID' ][, mixed $order = 'ASC' ][, mixed $ignoreClassType = false ][, mixed $constructorArgs = array() ]) : array<string|int, mixed>
Parameters
- $attribute : mixed
-
The attribute to load the objects by.
- $value : mixed
-
The value of the attribute to load the objects by.
- $start : mixed = 0
-
The start of the SQL LIMIT clause, useful for pagination.
- $limit : mixed = 0
-
The amount (limit) of objects to load, useful for pagination.
- $orderBy : mixed = 'ID'
-
The name of the field to sort the objects by.
- $order : mixed = 'ASC'
-
The order to sort the objects by.
- $ignoreClassType : mixed = false
-
Default is false, set to true if you want to load from overloaded tables and ignore the class type.
- $constructorArgs : mixed = array()
-
An optional array of contructor arguements to pass to the records that will be generated and returned. Supports a maximum of 5 arguements.
Tags
Return values
array<string|int, mixed>loadAllByAttributes()
(non-PHPdoc).
public
loadAllByAttributes([mixed $attributes = array() ][, mixed $values = array() ][, mixed $start = 0 ][, mixed $limit = 0 ][, mixed $orderBy = 'ID' ][, mixed $order = 'ASC' ][, mixed $ignoreClassType = false ][, mixed $constructorArgs = array() ]) : array<string|int, mixed>
Parameters
- $attributes : mixed = array()
-
The attributes to load the records by.
- $values : mixed = array()
-
The values of the attributes to load the records by.
- $start : mixed = 0
-
The start of the SQL LIMIT clause, useful for pagination.
- $limit : mixed = 0
-
The amount (limit) of records to load, useful for pagination.
- $orderBy : mixed = 'ID'
-
The name of the field to sort the records by.
- $order : mixed = 'ASC'
-
The order to sort the records by.
- $ignoreClassType : mixed = false
-
Default is false, set to true if you want to load from overloaded tables and ignore the class type
- $constructorArgs : mixed = array()
-
An optional array of contructor arguements to pass to the records that will be generated and returned. Supports a maximum of 5 arguements.
Tags
Return values
array<string|int, mixed>loadAllByDayUpdated()
(non-PHPdoc).
public
loadAllByDayUpdated(mixed $date[, mixed $start = 0 ][, mixed $limit = 0 ][, mixed $orderBy = 'ID' ][, mixed $order = 'ASC' ][, mixed $ignoreClassType = false ]) : array<string|int, mixed>
Parameters
- $date : mixed
-
The date for which to load the records updated on, in the format 'YYYY-MM-DD'.
- $start : mixed = 0
-
The start of the SQL LIMIT clause, useful for pagination.
- $limit : mixed = 0
-
The amount (limit) of records to load, useful for pagination.
- $orderBy : mixed = 'ID'
-
The name of the field to sort the records by.
- $order : mixed = 'ASC'
-
The order to sort the records by.
- $ignoreClassType : mixed = false
-
Default is false, set to true if you want to load from overloaded tables and ignore the class type
Tags
Return values
array<string|int, mixed>loadAllFieldValuesByAttribute()
(non-PHPdoc).
public
loadAllFieldValuesByAttribute(mixed $attribute, mixed $value, mixed $returnAttribute[, mixed $order = 'ASC' ][, mixed $ignoreClassType = false ]) : array<string|int, mixed>
Parameters
- $attribute : mixed
-
The attribute name to load the field values by.
- $value : mixed
-
The value of the attribute to load the field values by.
- $returnAttribute : mixed
-
The name of the attribute to return.
- $order : mixed = 'ASC'
-
The order to sort the records by.
- $ignoreClassType : mixed = false
-
Default is false, set to true if you want to load from overloaded tables and ignore the class type.
Tags
Return values
array<string|int, mixed>loadAllOldVersions()
(non-PHPdoc).
public
loadAllOldVersions(mixed $ID) : array<string|int, mixed>
Parameters
- $ID : mixed
-
The object ID of the record to load.
Tags
Return values
array<string|int, mixed>loadByAttribute()
(non-PHPdoc).
public
loadByAttribute(mixed $attribute, mixed $value[, mixed $ignoreClassType = false ][, mixed $loadAttributes = array() ]) : void
Parameters
- $attribute : mixed
-
The name of the attribute to load the record by.
- $value : mixed
-
The value of the attribute to load the record by.
- $ignoreClassType : mixed = false
-
Default is false, set to true if you want to load from overloaded tables and ignore the class type
- $loadAttributes : mixed = array()
-
The attributes to load from the database to this object (leave blank to load all attributes)
Tags
makeHistoryTable()
(non-PHPdoc).
public
makeHistoryTable() : void
Tags
makeTable()
(non-PHPdoc).
public
makeTable([mixed $checkIndexes = true ]) : void
Parameters
- $checkIndexes : mixed = true
-
Set to false if you do not want to check for any additional required indexes while creating the table (default is true).
Tags
query()
(non-PHPdoc).
public
query(mixed $sqlQuery) : array<string|int, mixed>
Parameters
- $sqlQuery : mixed
Tags
Return values
array<string|int, mixed>rebuildTable()
(non-PHPdoc).
public
rebuildTable() : void
Tags
reload()
(non-PHPdoc).
public
reload() : void
Tags
rollback()
(non-PHPdoc).
public
static rollback() : void
Tags
save()
(non-PHPdoc).
public
save() : void
Tags
saveAttribute()
(non-PHPdoc).
public
saveAttribute(mixed $attribute, mixed $value) : void
Parameters
- $attribute : mixed
-
The name of the attribute to save.
- $value : mixed
-
The value of the attribute to save.
Tags
saveHistory()
(non-PHPdoc).
public
saveHistory() : void
Tags
setEnumOptions()
(non-PHPdoc).
public
setEnumOptions() : void
Tags
setRecord()
(non-PHPdoc).
public
setRecord(mixed $record) : void
Parameters
- $record : mixed
Tags
bindParams()
Dynamically binds all of the attributes for the current Record to the supplied prepared statement parameters. If arrays of attribute names and values are provided, only those will be bound to the supplied statement.
private
bindParams(mysqli_stmt $stmt[, mixed $attributes = array() ][, mixed $values = array() ]) : mysqli_stmt
Parameters
- $stmt : mysqli_stmt
-
The SQL statement to bind to.
- $attributes : mixed = array()
- $values : mixed = array()
Tags
Return values
mysqli_stmtbindResult()
Dynamically binds the result of the supplied prepared statement to a 2d array, where each element in the array is another array representing a database row.
private
bindResult(mysqli_stmt $stmt) : array<string|int, mixed>
Parameters
- $stmt : mysqli_stmt
Tags
Return values
array<string|int, mixed>checkIndexes()
Checks to see if all of the indexes are in place for the record's table, creates those that are missing.
private
checkIndexes() : void
Tags
findOffendingValue()
Parses a MySQL error for the value that violated a unique constraint.
private
findOffendingValue(mixed $error) : string
Parameters
- $error : mixed