# Class AlphaDAOProviderSQLite

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

  AlphaDAOProviderSQLite implements AlphaDAOProviderInterface

Package: alpha::model
Copyright: Copyright (c) 2012, 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>
Version: $Id: AlphaDAOProviderSQLite.inc 1693 2013-12-09 23:33:24Z alphadevx $
Since: 1.2
Located at model/AlphaDAOProviderSQLite.inc

Methods summary
`public` | # `__construct( )` The constructor The constructor #### Since 1.2
`public static mysqli` | # `getConnection( )` (non-PHPdoc) (non-PHPdoc) #### Returns `mysqli` #### See alpha/model/AlphaDAOProviderInterface::getConnection() #### Implementation of `AlphaDAOProviderInterface::getConnection()`
`public static` | # `disconnect( )` (non-PHPdoc) (non-PHPdoc) #### See alpha/model/AlphaDAOProviderInterface::disconnect() #### Implementation of `AlphaDAOProviderInterface::disconnect()`
`public static string` | # `getLastDatabaseError( )` (non-PHPdoc) (non-PHPdoc) #### Returns `string` #### See alpha/model/AlphaDAOProviderInterface::getLastDatabaseError() #### Implementation of `AlphaDAOProviderInterface::getLastDatabaseError()`
`public array` | # `query( string $sqlQuery )` (non-PHPdoc) (non-PHPdoc) #### Parameters $sqlQuery `string` $sqlQuery #### Returns `array` #### Throws ``CustomQueryException`` #### See alpha/model/AlphaDAOProviderInterface::query() #### Implementation of `AlphaDAOProviderInterface::query()`
`public` | # `load( integer $OID )` (non-PHPdoc) (non-PHPdoc) #### Parameters $OID `integer` $OID The object ID of the business object to load. #### Throws ``BONotFoundException`` #### See alpha/model/AlphaDAOProviderInterface::load() #### Implementation of `AlphaDAOProviderInterface::load()`
`public` | # `loadByAttribute( string $attribute, string $value, boolean $ignoreClassType = false, array $loadAttributes = array() )` (non-PHPdoc) (non-PHPdoc) #### 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 `boolean` $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 ``BONotFoundException`` #### See alpha/model/AlphaDAOProviderInterface::loadByAttribute() #### Implementation of `AlphaDAOProviderInterface::loadByAttribute()`
`public array` | # `loadAll( integer $start = 0, integer $limit = 0, string $orderBy = 'OID', string $order = 'ASC', boolean $ignoreClassType = false )` (non-PHPdoc) (non-PHPdoc) #### Parameters $start `integer` $start The start of the SQL LIMIT clause, useful for pagination. $limit `integer` $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 `boolean` $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 ``BONotFoundException`` #### See alpha/model/AlphaDAOProviderInterface::loadAll() #### Implementation of `AlphaDAOProviderInterface::loadAll()`
`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() )` (non-PHPdoc) (non-PHPdoc) #### 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 `integer` $start The start of the SQL LIMIT clause, useful for pagination. $limit `integer` $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 `boolean` $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 ``BONotFoundException`` ``IllegalArguementException`` #### See alpha/model/AlphaDAOProviderInterface::loadAllByAttribute() #### Implementation of `AlphaDAOProviderInterface::loadAllByAttribute()`
`public array` | # `loadAllByAttributes( array $attributes = array(), array $values = array(), integer $start = 0, integer $limit = 0, string $orderBy = 'OID', string $order = 'ASC', boolean $ignoreClassType = false )` (non-PHPdoc) (non-PHPdoc) #### 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 `integer` $start The start of the SQL LIMIT clause, useful for pagination. $limit `integer` $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 `boolean` $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 ``BONotFoundException`` ``IllegalArguementException`` #### See alpha/model/AlphaDAOProviderInterface::loadAllByAttributes() #### Implementation of `AlphaDAOProviderInterface::loadAllByAttributes()`
`public array` | # `loadAllByDayUpdated( string $date, integer $start = 0, integer $limit = 0, string $orderBy = "OID", string $order = "ASC", boolean $ignoreClassType = false )` (non-PHPdoc) (non-PHPdoc) #### Parameters $date `string` $date The date for which to load the objects updated on, in the format 'YYYY-MM-DD'. $start `integer` $start The start of the SQL LIMIT clause, useful for pagination. $limit `integer` $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 `boolean` $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 ``BONotFoundException`` #### See alpha/model/AlphaDAOProviderInterface::loadAllByDayUpdated() #### Implementation of `AlphaDAOProviderInterface::loadAllByDayUpdated()`
`public array` | # `loadAllFieldValuesByAttribute( string $attribute, string $value, string $returnAttribute, string $order = 'ASC', boolean $ignoreClassType = false )` (non-PHPdoc) (non-PHPdoc) #### 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 `boolean` $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 ``BONotFoundException`` #### See alpha/model/AlphaDAOProviderInterface::loadAllFieldValuesByAttribute() #### Implementation of `AlphaDAOProviderInterface::loadAllFieldValuesByAttribute()`
`public` | # `save( )` (non-PHPdoc) (non-PHPdoc) #### Throws ``FailedSaveException`` ``LockingException`` ``ValidationException`` #### See alpha/model/AlphaDAOProviderInterface::save() #### Implementation of `AlphaDAOProviderInterface::save()`
`public` | # `saveAttribute( string $attribute, mixed $value )` (non-PHPdoc) (non-PHPdoc) #### Parameters $attribute `string` $attribute The name of the attribute to save. $value `mixed` $value The value of the attribute to save. #### Throws ``IllegalArguementException`` ``FailedSaveException`` #### See alpha/model/AlphaDAOProviderInterface::saveAttribute() #### Implementation of `AlphaDAOProviderInterface::saveAttribute()`
`public` | # `saveHistory( )` (non-PHPdoc) (non-PHPdoc) #### Throws ``FailedSaveException`` #### See alpha/model/AlphaDAOProviderInterface::saveHistory() #### Implementation of `AlphaDAOProviderInterface::saveHistory()`
`public` | # `delete( )` (non-PHPdoc) (non-PHPdoc) #### Throws ``FailedDeleteException`` #### See alpha/model/AlphaDAOProviderInterface::delete() #### Implementation of `AlphaDAOProviderInterface::delete()`
`public integer` | # `getVersion( )` (non-PHPdoc) (non-PHPdoc) #### Returns `integer` #### Throws ``BONotFoundException`` #### See alpha/model/AlphaDAOProviderInterface::getVersion() #### Implementation of `AlphaDAOProviderInterface::getVersion()`
`public` | # `makeTable( )` (non-PHPdoc) (non-PHPdoc) #### Throws ``AlphaException`` #### See alpha/model/AlphaDAOProviderInterface::makeTable() #### Implementation of `AlphaDAOProviderInterface::makeTable()`
`public` | # `makeHistoryTable( )` (non-PHPdoc) (non-PHPdoc) #### Throws ``AlphaException`` #### See alpha/model/AlphaDAOProviderInterface::makeHistoryTable() #### Implementation of `AlphaDAOProviderInterface::makeHistoryTable()`
`public` | # `rebuildTable( )` (non-PHPdoc) (non-PHPdoc) #### Throws ``AlphaException`` #### See alpha/model/AlphaDAOProviderInterface::rebuildTable() #### Implementation of `AlphaDAOProviderInterface::rebuildTable()`
`public` | # `dropTable( string $tableName = null )` (non-PHPdoc) (non-PHPdoc) #### Parameters $tableName `string` $tableName Optional table name, leave blank for the defined table for this class to be dropped #### Throws ``AlphaException`` #### See alpha/model/AlphaDAOProviderInterface::dropTable() #### Implementation of `AlphaDAOProviderInterface::dropTable()`
`public` | # `addProperty( string $propName )` (non-PHPdoc) (non-PHPdoc) #### Parameters $propName `string` $propName The name of the new field to add to the database table. #### Throws ``AlphaException`` #### See alpha/model/AlphaDAOProviderInterface::addProperty() #### Implementation of `AlphaDAOProviderInterface::addProperty()`
`public integer` | # `getMAX( )` (non-PHPdoc) (non-PHPdoc) #### Returns `integer` The maximum OID value in the class table. #### Throws ``AlphaException`` #### See alpha/model/AlphaDAOProviderInterface::getMAX() #### Implementation of `AlphaDAOProviderInterface::getMAX()`
`public integer` | # `getCount( array $attributes = array(), array $values = array() )` (non-PHPdoc) (non-PHPdoc) #### 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` #### Throws ``AlphaException`` #### See alpha/model/AlphaDAOProviderInterface::getCount() #### Implementation of `AlphaDAOProviderInterface::getCount()`
`public integer` | # `getHistoryCount( )` (non-PHPdoc) (non-PHPdoc) #### Returns `integer` #### Throws ``AlphaException`` #### See alpha/model/AlphaDAOProviderInterface::getHistoryCount() #### Implementation of `AlphaDAOProviderInterface::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 ``NotImplementedException`` #### See alpha/model/AlphaDAOProviderInterface::setEnumOptions() #### Implementation of `AlphaDAOProviderInterface::setEnumOptions()`
`public boolean` | # `checkTableExists( boolean $checkHistoryTable = false )` (non-PHPdoc) (non-PHPdoc) #### Parameters $checkHistoryTable `boolean` $checkHistoryTable Set to true if you want to check for the existance of the _history table for this DAO. #### Returns `boolean` #### Throws ``AlphaException`` #### See alpha/model/AlphaDAOProviderInterface::checkTableExists() #### Implementation of `AlphaDAOProviderInterface::checkTableExists()`
`public static boolean` | # `checkBOTableExists( string $BOClassName, boolean $checkHistoryTable = false )` (non-PHPdoc) (non-PHPdoc) #### Parameters $BOClassName `string` $BOClassName The name of the business object class we are checking. $checkHistoryTable `boolean` $checkHistoryTable Set to true if you want to check for the existance of the _history table for this DAO. #### Returns `boolean` #### Throws ``AlphaException`` #### See alpha/model/AlphaDAOProviderInterface::checkBOTableExists() #### Implementation of `AlphaDAOProviderInterface::checkBOTableExists()`
`public boolean` | # `checkTableNeedsUpdate( )` (non-PHPdoc) (non-PHPdoc) #### Returns `boolean` #### Throws ``AlphaException`` #### See alpha/model/AlphaDAOProviderInterface::checkTableNeedsUpdate() #### Implementation of `AlphaDAOProviderInterface::checkTableNeedsUpdate()`
`public array` | # `findMissingFields( )` (non-PHPdoc) (non-PHPdoc) #### Returns `array` An array of missing fields in the database table. #### Throws ``AlphaException`` #### See alpha/model/AlphaDAOProviderInterface::findMissingFields() #### Implementation of `AlphaDAOProviderInterface::findMissingFields()`
`public array` | # `getIndexes( )` (non-PHPdoc) (non-PHPdoc) #### Returns `array` An array of database indexes on this table. #### Throws ``AlphaException`` #### See alpha/model/AlphaDAOProviderInterface::getIndexes() #### Implementation of `AlphaDAOProviderInterface::getIndexes()`
`private` | # `checkIndexes( )` Checks to see if all of the indexes are in place for the BO's table, creates those that are missing. Checks to see if all of the indexes are in place for the BO's table, creates those that are missing. #### Since 1.2
`public` | # `createForeignIndex( string $attributeName, string $relatedClass, string $relatedClassAttribute )` 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 `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. #### Throws ``FailedIndexCreateException`` #### See alpha/model/AlphaDAOProviderInterface::createForeignIndex() #### Implementation of `AlphaDAOProviderInterface::createForeignIndex()`
`public` | # `createUniqueIndex( string $attribute1Name, string $attribute2Name = '', string $attribute3Name = '' )` (non-PHPdoc) (non-PHPdoc) #### 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 ``FailedIndexCreateException`` #### See alpha/model/AlphaDAOProviderInterface::createUniqueIndex() #### Implementation of `AlphaDAOProviderInterface::createUniqueIndex()`
`public` | # `reload( )` (non-PHPdoc) (non-PHPdoc) #### Throws ``AlphaException`` #### See alpha/model/AlphaDAOProviderInterface::reload() #### Implementation of `AlphaDAOProviderInterface::reload()`
`public boolean` | # `checkRecordExists( integer $OID )` (non-PHPdoc) (non-PHPdoc) #### Parameters $OID `integer` $OID The Object ID of the object we want to see whether it exists or not. #### Returns `boolean` #### Throws ``AlphaException`` #### See alpha/model/AlphaDAOProviderInterface::checkRecordExists() #### Implementation of `AlphaDAOProviderInterface::checkRecordExists()`
`public boolean` | # `isTableOverloaded( )` (non-PHPdoc) (non-PHPdoc) #### Returns `boolean` #### Throws ``BadBOTableNameException`` #### See alpha/model/AlphaDAOProviderInterface::isTableOverloaded() #### Implementation of `AlphaDAOProviderInterface::isTableOverloaded()`
`public static` | # `begin( )` (non-PHPdoc) (non-PHPdoc) #### Throws ``AlphaException`` #### See alpha/model/AlphaDAOProviderInterface::begin() #### Implementation of `AlphaDAOProviderInterface::begin()`
`public static` | # `commit( )` (non-PHPdoc) (non-PHPdoc) #### Throws ``FailedSaveException`` #### See alpha/model/AlphaDAOProviderInterface::commit() #### Implementation of `AlphaDAOProviderInterface::commit()`
`public static` | # `rollback( )` (non-PHPdoc) (non-PHPdoc) #### Throws ``AlphaException`` #### See alpha/model/AlphaDAOProviderInterface::rollback() #### Implementation of `AlphaDAOProviderInterface::rollback()`
`public` | # `setBO( `AlphaDAO` $BO )` (non-PHPdoc) (non-PHPdoc) #### Parameters $BO ``AlphaDAO`` $BO #### See alpha/model/AlphaDAOProviderInterface::setBO() #### Implementation of `AlphaDAOProviderInterface::setBO()`

Properties summary
`private static `Logger`` | $logger | `null` | # Trace logger Trace logger #### Since 1.2
`private static SQLite3` | $connection | `` | # Database connection Database connection #### Since 1.2
`private `AlphaDAO`` | $BO | `` | # The business object that we are mapping back to The business object that we are mapping back to #### Since 1.2