ActiveRecordProviderSQLite implements ActiveRecordProviderInterface
SQLite active record provider (uses the SQLite3 native API in PHP).
Tags
Interfaces, Classes and Traits
- ActiveRecordProviderInterface
- An interface that defines all of the active record methods that should be included in a provider that implements this interface.
Table of Contents
- $connection : SQLite3
- Database connection.
- $foreignKeys : array<string|int, mixed>
- An array of new foreign keys that need to be created.
- $logger : Logger
- Trace logger.
- $record : ActiveRecord
- The business object that we are mapping back to.
- __construct() : mixed
- The constructor.
- addProperty() : void
- (non-PHPdoc).
- backupDatabase() : mixed
- (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
- Note that SQLite 3.6.19 is requrired for foreign key support.
- 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() : mixed
- (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
- Given that Enum values are not saved in the database for SQLite, an implementation is not required here.
- setRecord() : void
- (non-PHPdoc).
- checkIndexes() : mixed
- Checks to see if all of the indexes are in place for the record's table, creates those that are missing.
Properties
$connection
Database connection.
private
static SQLite3
$connection
Tags
$foreignKeys
An array of new foreign keys that need to be created.
private
array<string|int, mixed>
$foreignKeys
= array()
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
Return values
mixed —addProperty()
(non-PHPdoc).
public
addProperty(mixed $propName) : void
Parameters
- $propName : mixed
-
The name of the new field to add to the database table.
Tags
Return values
void —backupDatabase()
(non-PHPdoc).
public
static backupDatabase(mixed $targetFile) : mixed
Parameters
- $targetFile : mixed
Tags
Return values
mixed —begin()
(non-PHPdoc).
public
static begin() : void
Tags
Return values
void —checkDatabaseExists()
(non-PHPdoc).
public
static checkDatabaseExists() : bool
Tags
Return values
bool —checkRecordExists()
(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
bool —checkRecordTableExists()
(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
bool —checkTableExists()
(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
bool —checkTableNeedsUpdate()
(non-PHPdoc).
public
checkTableNeedsUpdate() : bool
Tags
Return values
bool —commit()
(non-PHPdoc).
public
static commit() : void
Tags
Return values
void —createDatabase()
(non-PHPdoc).
public
static createDatabase() : void
Tags
Return values
void —createForeignIndex()
Note that SQLite 3.6.19 is requrired for foreign key support.
public
createForeignIndex(mixed $attributeName, mixed $relatedClass, mixed $relatedClassAttribute[, mixed $indexName = null ]) : void
(non-PHPdoc)
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
Return values
void —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
Return values
void —delete()
(non-PHPdoc).
public
delete() : void
Tags
Return values
void —disconnect()
(non-PHPdoc).
public
static disconnect() : void
Tags
Return values
void —dropDatabase()
(non-PHPdoc).
public
static dropDatabase() : void
Tags
Return values
void —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
Return values
void —findMissingFields()
(non-PHPdoc).
public
findMissingFields() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —An array of missing fields in the database table.
getConnection()
(non-PHPdoc).
public
static getConnection() : mixed
Tags
Return values
mixed —getCount()
(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
int —getHistoryCount()
(non-PHPdoc).
public
getHistoryCount() : int
Tags
Return values
int —getIndexes()
(non-PHPdoc).
public
getIndexes() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —An array of database indexes on this table.
getLastDatabaseError()
(non-PHPdoc).
public
static getLastDatabaseError() : string
Tags
Return values
string —getMAX()
(non-PHPdoc).
public
getMAX() : int
Tags
Return values
int —The maximum ID value in the class table.
getVersion()
(non-PHPdoc).
public
getVersion() : int
Tags
Return values
int —isTableOverloaded()
(non-PHPdoc).
public
isTableOverloaded() : bool
Tags
Return values
bool —load()
(non-PHPdoc).
public
load(mixed $ID, mixed $version) : void
Parameters
- $ID : mixed
-
The object ID of the record to load.
- $version : mixed
-
Optionaly, provide the version to load that version from the [tablename]_history table.
Tags
Return values
void —loadAll()
(non-PHPdoc).
public
loadAll(mixed $start, mixed $limit[, mixed $orderBy = 'ID' ][, mixed $order = 'ASC' ][, mixed $ignoreClassType = false ]) : array<string|int, mixed>
Parameters
- $start : mixed
-
The start of the SQL LIMIT clause, useful for pagination.
- $limit : mixed
-
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> —An array containing objects of this type of record object.
loadAllByAttribute()
(non-PHPdoc).
public
loadAllByAttribute(mixed $attribute, mixed $value, mixed $start, mixed $limit[, 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
-
The start of the SQL LIMIT clause, useful for pagination.
- $limit : mixed
-
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> —An array containing objects of this type of business object.
loadAllByAttributes()
(non-PHPdoc).
public
loadAllByAttributes([mixed $attributes = array() ][, mixed $values = array() ], mixed $start, mixed $limit[, 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
-
The start of the SQL LIMIT clause, useful for pagination.
- $limit : mixed
-
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> —An array containing objects of this type of record object.
loadAllByDayUpdated()
(non-PHPdoc).
public
loadAllByDayUpdated(mixed $date, mixed $start, mixed $limit[, 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
-
The start of the SQL LIMIT clause, useful for pagination.
- $limit : mixed
-
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> —An array containing objects of this type of record object.
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> —An array of field values.
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> —An array containing objects of this type of record object, order by version.
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
Return values
void —makeHistoryTable()
(non-PHPdoc).
public
makeHistoryTable() : void
Tags
Return values
void —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
Return values
void —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
Return values
void —reload()
(non-PHPdoc).
public
reload() : void
Tags
Return values
void —rollback()
(non-PHPdoc).
public
static rollback() : void
Tags
Return values
void —save()
(non-PHPdoc).
public
save() : void
Tags
Return values
void —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
Return values
void —saveHistory()
(non-PHPdoc).
public
saveHistory() : void
Tags
Return values
void —setEnumOptions()
Given that Enum values are not saved in the database for SQLite, an implementation is not required here.
public
setEnumOptions() : void
(non-PHPdoc)
Tags
Return values
void —setRecord()
(non-PHPdoc).
public
setRecord(mixed $Record) : void
Parameters
- $Record : mixed
Tags
Return values
void —checkIndexes()
Checks to see if all of the indexes are in place for the record's table, creates those that are missing.
private
checkIndexes() : mixed