Alpha Framework 3.0.0 API Documentation
  • Namespace
  • Class

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
      • Service
    • View
      • Renderer
        • Html
        • Json
      • Widget

Classes

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

Interfaces

  • ActiveRecordProviderInterface

Class ActiveRecordProviderSQLite

SQLite active record provider (uses the SQLite3 native API in PHP).

Alpha\Model\ActiveRecordProviderSQLite implements Alpha\Model\ActiveRecordProviderInterface
Namespace: Alpha\Model
Copyright:

Copyright (c) 2018, 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.

License: The BSD License
Author: John Collins dev@alphaframework.org
Since: 1.2
Located at Model/ActiveRecordProviderSQLite.php

Methods summary

public
# __construct( )

The constructor.

The constructor.

Since

1.2
public static mixed
# getConnection( )

(non-PHPdoc).

(non-PHPdoc).

Returns

mixed

See

Alpha\Model\ActiveRecordProviderInterface::getConnection()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::getConnection()
public static
# disconnect( )

(non-PHPdoc).

(non-PHPdoc).

See

Alpha\Model\ActiveRecordProviderInterface::disconnect()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::disconnect()
public static string
# getLastDatabaseError( )

(non-PHPdoc).

(non-PHPdoc).

Returns

string

See

Alpha\Model\ActiveRecordProviderInterface::getLastDatabaseError()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::getLastDatabaseError()
public array
# query( string $sqlQuery )

(non-PHPdoc).

(non-PHPdoc).

Parameters

$sqlQuery

Returns

array

Throws

Alpha\Exception\CustomQueryException

See

Alpha\Model\ActiveRecordProviderInterface::query()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::query()
public
# load( integer $ID, integer $version = 0 )

(non-PHPdoc).

(non-PHPdoc).

Parameters

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

Throws

Alpha\Exception\RecordFoundException

See

Alpha\Model\ActiveRecordProviderInterface::load()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::load()
public array
# loadAllOldVersions( integer $ID )

(non-PHPdoc).

(non-PHPdoc).

Parameters

$ID
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

See

Alpha\Model\ActiveRecordProviderInterface::loadAllOldVersions()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::loadAllOldVersions()
public
# loadByAttribute( string $attribute, string $value, boolean $ignoreClassType = false, array $loadAttributes = array() )

(non-PHPdoc).

(non-PHPdoc).

Parameters

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

Throws

Alpha\Exception\RecordFoundException

See

Alpha\Model\ActiveRecordProviderInterface::loadByAttribute()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::loadByAttribute()
public array
# loadAll( integer $start = 0, integer $limit = 0, string $orderBy = 'ID', string $order = 'ASC', boolean $ignoreClassType = false )

(non-PHPdoc).

(non-PHPdoc).

Parameters

$start
The start of the SQL LIMIT clause, useful for pagination.
$limit
The amount (limit) of records to load, useful for pagination.
$orderBy
The name of the field to sort the records by.
$order
The order to sort the records by.
$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 record object.

Throws

Alpha\Exception\RecordFoundException

See

Alpha\Model\ActiveRecordProviderInterface::loadAll()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::loadAll()
public array
# loadAllByAttribute( string $attribute, string $value, integer $start = 0, integer $limit = 0, string $orderBy = 'ID', string $order = 'ASC', boolean $ignoreClassType = false, string[] $constructorArgs = array() )

(non-PHPdoc).

(non-PHPdoc).

Parameters

$attribute
The attribute to load the objects by.
$value
The value of the attribute to load the objects by.
$start
The start of the SQL LIMIT clause, useful for pagination.
$limit
The amount (limit) of objects to load, useful for pagination.
$orderBy
The name of the field to sort the objects by.
$order
The order to sort the objects by.
$ignoreClassType
Default is false, set to true if you want to load from overloaded tables and ignore the class type.
$constructorArgs
An optional array of contructor arguements to pass to the records 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\RecordFoundException
Alpha\Exception\IllegalArguementException

See

Alpha\Model\ActiveRecordProviderInterface::loadAllByAttribute()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::loadAllByAttribute()
public array
# loadAllByAttributes( array $attributes = array(), array $values = array(), integer $start = 0, integer $limit = 0, string $orderBy = 'ID', string $order = 'ASC', boolean $ignoreClassType = false, string[] $constructorArgs = array() )

(non-PHPdoc).

(non-PHPdoc).

Parameters

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

Returns

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

Throws

Alpha\Exception\RecordFoundException
Alpha\Exception\IllegalArguementException

See

Alpha\Model\ActiveRecordProviderInterface::loadAllByAttributes()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::loadAllByAttributes()
public array
# loadAllByDayUpdated( string $date, integer $start = 0, integer $limit = 0, string $orderBy = 'ID', string $order = 'ASC', boolean $ignoreClassType = false )

(non-PHPdoc).

(non-PHPdoc).

Parameters

$date
The date for which to load the records updated on, in the format 'YYYY-MM-DD'.
$start
The start of the SQL LIMIT clause, useful for pagination.
$limit
The amount (limit) of records to load, useful for pagination.
$orderBy
The name of the field to sort the records by.
$order
The order to sort the records by.
$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 record object.

Throws

Alpha\Exception\RecordFoundException

See

Alpha\Model\ActiveRecordProviderInterface::loadAllByDayUpdated()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::loadAllByDayUpdated()
public array
# loadAllFieldValuesByAttribute( string $attribute, string $value, string $returnAttribute, string $order = 'ASC', boolean $ignoreClassType = false )

(non-PHPdoc).

(non-PHPdoc).

Parameters

$attribute
The attribute name to load the field values by.
$value
The value of the attribute to load the field values by.
$returnAttribute
The name of the attribute to return.
$order
The order to sort the records by.
$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\RecordFoundException

See

Alpha\Model\ActiveRecordProviderInterface::loadAllFieldValuesByAttribute()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::loadAllFieldValuesByAttribute()
public
# save( )

(non-PHPdoc).

(non-PHPdoc).

Throws

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

See

Alpha\Model\ActiveRecordProviderInterface::save()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::save()
public
# saveAttribute( string $attribute, mixed $value )

(non-PHPdoc).

(non-PHPdoc).

Parameters

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

Throws

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

See

Alpha\Model\ActiveRecordProviderInterface::saveAttribute()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::saveAttribute()
public
# saveHistory( )

(non-PHPdoc).

(non-PHPdoc).

Throws

Alpha\Exception\FailedSaveException

See

Alpha\Model\ActiveRecordProviderInterface::saveHistory()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::saveHistory()
public
# delete( )

(non-PHPdoc).

(non-PHPdoc).

Throws

Alpha\Exception\FailedDeleteException

See

Alpha\Model\ActiveRecordProviderInterface::delete()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::delete()
public integer
# getVersion( )

(non-PHPdoc).

(non-PHPdoc).

Returns

integer

Throws

Alpha\Exception\RecordFoundException

See

Alpha\Model\ActiveRecordProviderInterface::getVersion()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::getVersion()
public
# makeTable( boolean $checkIndexes = true )

(non-PHPdoc).

(non-PHPdoc).

Parameters

$checkIndexes
Set to false if you do not want to check for any additional required indexes while creating the table (default is true).

Throws

Alpha\Exception\AlphaException

See

Alpha\Model\ActiveRecordProviderInterface::makeTable()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::makeTable()
public
# makeHistoryTable( )

(non-PHPdoc).

(non-PHPdoc).

Throws

AlphaException

See

Alpha\Model\ActiveRecordProviderInterface::makeHistoryTable()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::makeHistoryTable()
public
# rebuildTable( )

(non-PHPdoc).

(non-PHPdoc).

Throws

Alpha\Exception\AlphaException

See

Alpha\Model\ActiveRecordProviderInterface::rebuildTable()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::rebuildTable()
public
# dropTable( string $tableName = null )

(non-PHPdoc).

(non-PHPdoc).

Parameters

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

Throws

Alpha\Exception\AlphaException

See

Alpha\Model\ActiveRecordProviderInterface::dropTable()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::dropTable()
public
# addProperty( string $propName )

(non-PHPdoc).

(non-PHPdoc).

Parameters

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

Throws

Alpha\Exception\AlphaException

See

Alpha\Model\ActiveRecordProviderInterface::addProperty()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::addProperty()
public integer
# getMAX( )

(non-PHPdoc).

(non-PHPdoc).

Returns

integer
The maximum ID value in the class table.

Throws

Alpha\Exception\AlphaException

See

Alpha\Model\ActiveRecordProviderInterface::getMAX()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::getMAX()
public integer
# getCount( array $attributes = array(), array $values = array() )

(non-PHPdoc).

(non-PHPdoc).

Parameters

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

Returns

integer

Throws

Alpha\Exception\AlphaException

See

Alpha\Model\ActiveRecordProviderInterface::getCount()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::getCount()
public integer
# getHistoryCount( )

(non-PHPdoc).

(non-PHPdoc).

Returns

integer

Throws

Alpha\Exception\AlphaException

See

Alpha\Model\ActiveRecordProviderInterface::getHistoryCount()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::getHistoryCount()
public
# setEnumOptions( )

Given that Enum values are not saved in the database for SQLite, an implementation is not required here.

Given that Enum values are not saved in the database for SQLite, an implementation is not required here.

(non-PHPdoc)

Throws

Alpha\Exception\NotImplementedException

See

Alpha\Model\ActiveRecordProviderInterface::setEnumOptions()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::setEnumOptions()
public boolean
# checkTableExists( boolean $checkHistoryTable = false )

(non-PHPdoc).

(non-PHPdoc).

Parameters

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

Returns

boolean

Throws

Alpha\Exception\AlphaException

See

Alpha\Model\ActiveRecordProviderInterface::checkTableExists()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::checkTableExists()
public static boolean
# checkRecordTableExists( string $RecordClassName, boolean $checkHistoryTable = false )

(non-PHPdoc).

(non-PHPdoc).

Parameters

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

Returns

boolean

Throws

Alpha\Exception\AlphaException
Alpha\Exception\IllegalArguementException

See

Alpha\Model\ActiveRecordProviderInterface::checkRecordTableExists()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::checkRecordTableExists()
public boolean
# checkTableNeedsUpdate( )

(non-PHPdoc).

(non-PHPdoc).

Returns

boolean

Throws

Alpha\Exception\AlphaException

See

Alpha\Model\ActiveRecordProviderInterface::checkTableNeedsUpdate()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::checkTableNeedsUpdate()
public array
# findMissingFields( )

(non-PHPdoc).

(non-PHPdoc).

Returns

array
An array of missing fields in the database table.

Throws

Alpha\Exception\AlphaException

See

Alpha\Model\ActiveRecordProviderInterface::findMissingFields()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::findMissingFields()
public array
# getIndexes( )

(non-PHPdoc).

(non-PHPdoc).

Returns

array
An array of database indexes on this table.

Throws

Alpha\Exception\AlphaException

See

Alpha\Model\ActiveRecordProviderInterface::getIndexes()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::getIndexes()
public
# createForeignIndex( string $attributeName, string $relatedClass, string $relatedClassAttribute, string $indexName = null )

Note that SQLite 3.6.19 is requrired for foreign key support.

Note that SQLite 3.6.19 is requrired for foreign key support.

(non-PHPdoc)

Parameters

$attributeName
The name of the attribute to apply the index on.
$relatedClass
The fully-qualified name of the related class.
$relatedClassAttribute
The name of the field to relate to on the related class.
$indexName
The optional name for the index, will calculate if not provided.

Throws

Alpha\Exception\FailedIndexCreateException

See

Alpha\Model\ActiveRecordProviderInterface::createForeignIndex()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::createForeignIndex()
public
# createUniqueIndex( string $attribute1Name, string $attribute2Name = '', string $attribute3Name = '' )

(non-PHPdoc).

(non-PHPdoc).

Parameters

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

Throws

Alpha\Exception\FailedIndexCreateException

See

Alpha\Model\ActiveRecordProviderInterface::createUniqueIndex()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::createUniqueIndex()
public
# reload( )

(non-PHPdoc).

(non-PHPdoc).

Throws

Alpha\Exception\AlphaException

See

Alpha\Model\ActiveRecordProviderInterface::reload()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::reload()
public boolean
# checkRecordExists( integer $ID )

(non-PHPdoc).

(non-PHPdoc).

Parameters

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

Returns

boolean

Throws

Alpha\Exception\AlphaException

See

Alpha\Model\ActiveRecordProviderInterface::checkRecordExists()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::checkRecordExists()
public boolean
# isTableOverloaded( )

(non-PHPdoc).

(non-PHPdoc).

Returns

boolean

Throws

Alpha\Exception\BadTableNameException

See

Alpha\Model\ActiveRecordProviderInterface::isTableOverloaded()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::isTableOverloaded()
public static
# begin( )

(non-PHPdoc).

(non-PHPdoc).

Throws

Alpha\Exception\AlphaException

See

Alpha\Model\ActiveRecordProviderInterface::begin()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::begin()
public static
# commit( )

(non-PHPdoc).

(non-PHPdoc).

Throws

Alpha\Exception\FailedSaveException

See

Alpha\Model\ActiveRecordProviderInterface::commit()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::commit()
public static
# rollback( )

(non-PHPdoc).

(non-PHPdoc).

Throws

Alpha\Exception\AlphaException

See

Alpha\Model\ActiveRecordProviderInterface::rollback()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::rollback()
public
# setRecord( Alpha\Model\ActiveRecord $Record )

(non-PHPdoc).

(non-PHPdoc).

Parameters

$Record

See

Alpha\Model\ActiveRecordProviderInterface::setRecord()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::setRecord()
public static boolean
# checkDatabaseExists( )

(non-PHPdoc).

(non-PHPdoc).

Returns

boolean

See

Alpha\Model\ActiveRecordProviderInterface::checkDatabaseExists()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::checkDatabaseExists()
public static
# createDatabase( )

(non-PHPdoc).

(non-PHPdoc).

Throws

Alpha\Exception\AlphaException

See

Alpha\Model\ActiveRecordProviderInterface::createDatabase()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::createDatabase()
public static
# dropDatabase( )

(non-PHPdoc).

(non-PHPdoc).

Throws

Alpha\Exception\AlphaException

See

Alpha\Model\ActiveRecordProviderInterface::dropDatabase()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::dropDatabase()
public static
# backupDatabase( $targetFile )

(non-PHPdoc).

(non-PHPdoc).

See

Alpha\Model\ActiveRecordProviderInterface::backupDatabase()
Alpha Framework 3.0.0 API Documentation API documentation generated by ApiGen